auto_go_route_generator 2.0.0
auto_go_route_generator: ^2.0.0 copied to clipboard
Code generator for auto_go_route. Turns route annotations into type-safe go_router routes, typed URL builders and navigation extensions.
Example #
This package is a build_runner generator: it has no runtime API of its own,
so there is nothing to demonstrate here in isolation.
The worked example is the app in the runtime package's repository, which exercises every annotation this generator reads:
https://github.com/itsarvinddev/auto_go_route/tree/main/example
The short version — add the generator as a dev_dependency, annotate a widget,
and run the builder:
dependencies:
auto_go_route: ^2.0.0
dev_dependencies:
auto_go_route_generator: ^2.0.0
build_runner: ^2.15.1
// lib/home_page.dart
@AutoGoRoute(path: '/home')
class HomePage extends StatelessWidget {
const HomePage({super.key});
// ...
}
// lib/app_router.dart
import 'package:auto_go_route/auto_go_route.dart';
import 'home_page.dart';
part 'app_router.routes.g.dart';
@AutoGoRouteBase(initialLocation: '/home')
class AppRouter extends _$AppRouter {}
dart run build_runner build
final router = AppRouter().buildRouter();
// ...
context.goToHomePage();
Full documentation: https://pub.dev/packages/auto_go_route.