-
Notifications
You must be signed in to change notification settings - Fork 189
Description
π 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 topubspec.yaml
- Create
AppRouter
class with@AutoRouterConfig
annotation - Define routes using
@RoutePage
annotations on page widgets - Generate routing code using
build_runner
- Replace
MaterialApp
withMaterialApp.router
- Update all
Navigator.pushNamed
calls to usecontext.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
- Backend
- Frontend
- Infrastructure
- DevOps
- Other
βοΈ 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:
- Update pubspec.yaml dependencies
- Create router configuration
- Annotate existing pages
- Generate routing code
- Update main.dart
- Replace all navigation calls
- Test all navigation flows
- Update CI/CD pipeline for
build_runner
- Update development documentation
- Configure IDE/editor for generated files
π Code of Conduct
- β I agree to the Code of Conduct