Skip to content

fix(templates): resolve GetX strict analyzer warnings and refactor auth UI to GetView#42

Open
codebyforam wants to merge 2 commits into
Arjun544:mainfrom
codebyforam:fix/getx-templates
Open

fix(templates): resolve GetX strict analyzer warnings and refactor auth UI to GetView#42
codebyforam wants to merge 2 commits into
Arjun544:mainfrom
codebyforam:fix/getx-templates

Conversation

@codebyforam
Copy link
Copy Markdown

@codebyforam codebyforam commented May 25, 2026

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?

  • Auth UI: Refactored the generated Authentication screens to leverage GetX's native GetView<AuthController> paradigm instead of storing controllers locally inside standard StatelessWidgets.
  • Controller Lifecycle: Updated the AuthController generation logic to properly instantiate and cleanly dispose of TextEditingController instances on close.
  • Analyzer Compliance: Resolved all implicit generic inference warnings (strict_raw_type) on GetPage arrays and Get.offAllNamed navigators.
  • Dependency Deduplication: Patched pubspec.yaml.hbs to prevent duplicate get: ^4.7.3 entries which were causing flutter pub get failures.
  • Import Collisions: Safely hid Trans and ContextExtensionss from the global GetX import barrel to prevent conflicts with standard localization and screen utility packages.

Testing:
Locally verified by running bun scripts/template-dev.ts with Git and Node.js.
The generated project passes flutter pub get and dart analyze with 0 issues.

Summary by CodeRabbit

  • Refactor

    • Improved GetX integration across Flutter templates with explicit generics for routing and typed navigation.
    • Simplified and consolidated import/export bundles and adjusted auth controller import paths.
    • Reworked auth screens to use GetX views that drive UI from controller-managed form fields and state.
  • Bug Fixes

    • Added proper disposal/cleanup for authentication controllers and adjusted navigation transitions.
  • Chores

    • Made the Get dependency conditional in the generated pubspec.

Review Change Stack

…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.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

@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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f40670f5-be55-4485-90aa-93fa4a24a41e

📥 Commits

Reviewing files that changed from the base of the PR and between 0a8ea34 and a524c2d.

📒 Files selected for processing (3)
  • templates/flutter/partials/features/auth/forgot_password_screen.hbs
  • templates/flutter/partials/features/auth/login_screen.hbs
  • templates/flutter/partials/features/auth/signup_screen.hbs
💤 Files with no reviewable changes (3)
  • templates/flutter/partials/features/auth/forgot_password_screen.hbs
  • templates/flutter/partials/features/auth/login_screen.hbs
  • templates/flutter/partials/features/auth/signup_screen.hbs

📝 Walkthrough

Walkthrough

This 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 <dynamic> generics are added throughout routing, and auth screens are rewritten as GetView<AuthController> widgets that delegate form state management to the centralized controller.

Changes

GetX Type Safety and Screen Architecture Refactoring

Layer / File(s) Summary
GetX Export Consolidation
templates/flutter/base/lib/src/imports/packages_imports.dart.hbs, templates/flutter/base/pubspec.yaml.hbs
GetX subpackage exports consolidated to single package:get/get.dart export hiding conflicting symbols (ContextExtensionss, Trans, StringExtension). The get dependency in pubspec is now conditional, included only when router package is not GetX.
GetX Routing Type Signatures
templates/flutter/base/lib/src/routing/app_router.dart.hbs, templates/flutter/base/lib/src/shared/wrappers/session_listener_wrapper.dart.hbs, templates/flutter/partials/features/auth/auth_logic.hbs
Explicit <dynamic> generic type arguments added to GetPage<dynamic>() route constructors, Get.offAllNamed<dynamic>() calls in session listener, and auth controller navigation methods (Get.offAllNamed<dynamic>(), Get.offNamed<dynamic>()).
App Configuration Updates
templates/flutter/base/lib/src/app.dart.hbs
Top-level app import switched from core_imports.dart to imports.dart to align with consolidated export structure.
AuthController Path Migration and Form State
templates/flutter/base/lib/src/routing/(isGetX)@app_bindings.dart.hbs``, templates/flutter/partials/features/auth/auth_logic.hbs, `templates/flutter/partials/features/auth/forgot_password_screen.hbs`, `templates/flutter/partials/features/auth/login_screen.hbs`, `templates/flutter/partials/features/auth/signup_screen.hbs`
AuthController import paths updated from controllers/ to providers/ directory (default branch). Form keys, text controllers, password-obscure reactive flags, and resource cleanup lifecycle added to AuthController for login, sign-up, and forgot-password flows.
Auth Screens Refactoring to GetView Pattern
templates/flutter/partials/features/auth/forgot_password_screen.hbs, templates/flutter/partials/features/auth/login_screen.hbs, templates/flutter/partials/features/auth/signup_screen.hbs
ForgotPasswordScreen, LoginScreen, and SignupScreen converted from hook-based/stateful widgets to GetView<AuthController> with form validation and submission delegated to controller methods. Form state and password visibility now managed by controller-owned text controllers and reactive flags, with reactive loading state driven by Obx.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • #37: Updates GetX exports to hide conflicting symbols, migrates AuthController paths from controllers/ to providers/, and adds explicit <dynamic> generics to GetX navigation—same core fixes as this PR.

Poem

🐰 I hopped through templates late at night,

Tucked GetX exports into one neat light,
Routes now typed with tidy care,
Controllers hold forms, all laid bare,
Screens sing Obx and everything's right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately captures the main objectives: resolving GetX strict analyzer warnings and refactoring auth UI to use GetView pattern, which are clearly reflected in the changeset across multiple template files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
templates/flutter/partials/features/auth/login_screen.hbs (1)

22-28: ⚡ Quick win

Avoid 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

📥 Commits

Reviewing files that changed from the base of the PR and between 248ec2e and 0a8ea34.

📒 Files selected for processing (10)
  • templates/flutter/base/lib/src/app.dart.hbs
  • templates/flutter/base/lib/src/imports/packages_imports.dart.hbs
  • templates/flutter/base/lib/src/routing/(isGetX)@app_bindings.dart.hbs``
  • templates/flutter/base/lib/src/routing/app_router.dart.hbs
  • templates/flutter/base/lib/src/shared/wrappers/session_listener_wrapper.dart.hbs
  • templates/flutter/base/pubspec.yaml.hbs
  • templates/flutter/partials/features/auth/auth_logic.hbs
  • templates/flutter/partials/features/auth/forgot_password_screen.hbs
  • templates/flutter/partials/features/auth/login_screen.hbs
  • templates/flutter/partials/features/auth/signup_screen.hbs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant