fix(templates): resolve GetX strict analyzer warnings and refactor auth UI to GetView#42
fix(templates): resolve GetX strict analyzer warnings and refactor auth UI to GetView#42codebyforam wants to merge 2 commits into
Conversation
…th UI to GetView
This commit addresses several Dart compilation issues and GetX anti-patterns
within the generator templates when `feature-first` and `getx` are selected:
1. UI Architecture Refactor (`GetView`)
- Migrated `login_screen`, `signup_screen`, and `forgot_password_screen`
from standard `StatelessWidget` to conditionally extend `GetView<AuthController>`
when GetX is enabled.
- Pushed mutable state (e.g. `obscureText`), `TextEditingController` instances,
and `GlobalKey<FormState>` keys out of the UI and into `AuthController`.
- Injected proper `onClose()` cleanup logic into `auth_logic.hbs` to prevent
memory leaks.
2. Import & Routing Conflicts
- Added `hide ContextExtensionss, Trans, StringExtension;` to the global
GetX export in `packages_imports.dart.hbs` to prevent ambiguous conflicts
with ScreenUtil and EasyLocalization.
- Removed redundant individual screen imports in `app_router.dart.hbs`
(GetX section) since `imports.dart` already exposes them.
- Fixed `app_bindings.dart.hbs` import path to correctly target the `providers/`
directory for `feature-first` instead of `controllers/`.
- Updated `app.dart.hbs` to use `imports.dart` instead of `core_imports.dart`
so `GetMaterialApp` is properly defined.
3. Strict Type Inference & YAML Fixes
- Upgraded `List<GetPage>` to explicit `List<GetPage<dynamic>>` in `app_router.dart.hbs`.
- Upgraded raw navigation calls like `Get.offAllNamed(...)` to explicit
`Get.offAllNamed<dynamic>(...)` in `session_listener_wrapper.dart.hbs`.
- Wrapped the GetX state-management dependency in `pubspec.yaml.hbs` with an
`{{#unless}}` block to prevent fatal YAML `Duplicate mapping key` errors
when GetX is used for both State Management and Routing simultaneously.
These changes guarantee that generating a GetX + feature-first template
compiles cleanly with exactly `0` `flutter analyze` errors.
|
@codebyforam is attempting to deploy a commit to the arjun544's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (3)
📝 WalkthroughWalkthroughThis PR refactors GetX integration across the Flutter template generator to improve type safety, consolidate exports, and standardize auth screen architecture. GetX subpackage exports are unified into a single import with hidden symbols, explicit ChangesGetX Type Safety and Screen Architecture Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
templates/flutter/partials/features/auth/login_screen.hbs (1)
22-28: ⚡ Quick winAvoid emitting
@RoutePage()twice for GetX + auto_route.Line 23 already conditionally emits
@RoutePage(), and Lines 26–28 emit it again in the GetX branch. Please keep only one annotation for this class path.✂️ Proposed fix
{{`#if` (eq flags.routerPackage "auto_route")}} `@RoutePage`() {{/if}} {{`#if` flags.isGetX}} -{{`#if` (eq flags.routerPackage "auto_route")}} -@RoutePage() -{{/if}} class LoginScreen extends GetView<AuthController> {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@templates/flutter/partials/features/auth/login_screen.hbs` around lines 22 - 28, The template emits the `@RoutePage`() annotation twice when flags.isGetX and flags.routerPackage == "auto_route"; remove the redundant annotation by consolidating the condition so `@RoutePage`() is rendered only once — e.g., keep a single conditional that checks (eq flags.routerPackage "auto_route") and do not re-emit it inside the flags.isGetX branch; update the login_screen.hbs template so the only occurrences of `@RoutePage`() are the single conditional based on flags.routerPackage ("auto_route").
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@templates/flutter/partials/features/auth/login_screen.hbs`:
- Around line 22-28: The template emits the `@RoutePage`() annotation twice when
flags.isGetX and flags.routerPackage == "auto_route"; remove the redundant
annotation by consolidating the condition so `@RoutePage`() is rendered only once
— e.g., keep a single conditional that checks (eq flags.routerPackage
"auto_route") and do not re-emit it inside the flags.isGetX branch; update the
login_screen.hbs template so the only occurrences of `@RoutePage`() are the single
conditional based on flags.routerPackage ("auto_route").
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a1a8b6c4-ed32-4ecf-a5ad-29a4d650a101
📒 Files selected for processing (10)
templates/flutter/base/lib/src/app.dart.hbstemplates/flutter/base/lib/src/imports/packages_imports.dart.hbstemplates/flutter/base/lib/src/routing/(isGetX)@app_bindings.dart.hbs``templates/flutter/base/lib/src/routing/app_router.dart.hbstemplates/flutter/base/lib/src/shared/wrappers/session_listener_wrapper.dart.hbstemplates/flutter/base/pubspec.yaml.hbstemplates/flutter/partials/features/auth/auth_logic.hbstemplates/flutter/partials/features/auth/forgot_password_screen.hbstemplates/flutter/partials/features/auth/login_screen.hbstemplates/flutter/partials/features/auth/signup_screen.hbs
Description:
This PR introduces stability and architectural fixes to the Flutter generator templates, specifically targeting configurations that utilize GetX alongside the Feature-First architecture.
What was changed?
GetView<AuthController>paradigm instead of storing controllers locally inside standard StatelessWidgets.AuthControllergeneration logic to properly instantiate and cleanly dispose ofTextEditingControllerinstances on close.strict_raw_type) onGetPagearrays andGet.offAllNamednavigators.pubspec.yaml.hbsto prevent duplicateget: ^4.7.3entries which were causingflutter pub getfailures.TransandContextExtensionssfrom the global GetX import barrel to prevent conflicts with standard localization and screen utility packages.Testing:
Locally verified by running
bun scripts/template-dev.tswith Git and Node.js.The generated project passes
flutter pub getanddart analyzewith 0 issues.Summary by CodeRabbit
Refactor
Bug Fixes
Chores