📝 Improvement Description
Migrate from the default Flutter routing system to auto_route package for better type-safe navigation, code generation, and improved developer experience.
🛑 Problem Statement
The current default routing system lacks type safety, requires manual route configuration, and makes navigation code verbose and error-prone. String-based route names are difficult to maintain and refactor, leading to runtime errors and poor developer experience.
💡 Proposed Solution
- Add
auto_route dependency to pubspec.yaml
- Create
AppRouter class with @AutoRouterConfig annotation
- Define routes using
@RoutePage annotations on page widgets
- Generate routing code using
build_runner
- Replace
MaterialApp with MaterialApp.router
- Update all
Navigator.pushNamed calls to use context.router.push()
- Implement nested routing where applicable
- Add route guards for authentication if needed
🌿 Benefits
- Type-safe routing with compile-time error checking
- Code generation reduces boilerplate and human errors
- Better IDE support with auto-completion for routes
- Easier refactoring and maintenance
- Support for nested routing and complex navigation patterns
- Built-in route guards and middleware support
- Improved developer experience and productivity
- Better testability of navigation logic
🧱 Impact Area
✍️ Additional Context
Related packages to consider:
- auto_route
- auto_route_generator
- build_runner
Build Runner Introduction Consequences:
🔄 Development workflow: Requires running dart run build_runner build after route changes
🏗️ CI/CD impact: Build pipelines must include code generation step before compilation
📁 Git considerations: Generated files (*.gr.dart) shouldn't be committed to version control
👥 Team coordination: All developers must run build_runner after pulling route changes
⏱️ Build time: Initial setup and route changes will slightly increase build duration
🐛 Debugging: Generated code may complicate stack traces and debugging
📦 Dependency management: Additional dev dependencies increase project complexity
💻 IDE integration: Some IDEs may require restart after code generation
Migration checklist:
📜 Code of Conduct
📝 Improvement Description
Migrate from the default Flutter routing system to
auto_routepackage for better type-safe navigation, code generation, and improved developer experience.🛑 Problem Statement
The current default routing system lacks type safety, requires manual route configuration, and makes navigation code verbose and error-prone. String-based route names are difficult to maintain and refactor, leading to runtime errors and poor developer experience.
💡 Proposed Solution
auto_routedependency topubspec.yamlAppRouterclass with@AutoRouterConfigannotation@RoutePageannotations on page widgetsbuild_runnerMaterialAppwithMaterialApp.routerNavigator.pushNamedcalls to usecontext.router.push()🌿 Benefits
🧱 Impact Area
✍️ Additional Context
Related packages to consider:
Build Runner Introduction Consequences:
🔄 Development workflow: Requires running
dart run build_runner buildafter route changes🏗️ CI/CD impact: Build pipelines must include code generation step before compilation
📁 Git considerations: Generated files (*.gr.dart) shouldn't be committed to version control
👥 Team coordination: All developers must run build_runner after pulling route changes
⏱️ Build time: Initial setup and route changes will slightly increase build duration
🐛 Debugging: Generated code may complicate stack traces and debugging
📦 Dependency management: Additional dev dependencies increase project complexity
💻 IDE integration: Some IDEs may require restart after code generation
Migration checklist:
build_runner📜 Code of Conduct