Home

GoRouter Modular

GoRouter Modular Banner

Modular architecture for Flutter apps. Build scalable applications with clean modules, built-in dependency injection, and powerful routing — all on top of go_router (opens in a new tab).

Install

flutter pub add go_router_modular

Minimal Example

lib/main.dart
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Modular.configure(
    appModule: AppModule(),
    initialRoute: '/',
  );
  runApp(AppWidget());
}
lib/src/app_widget.dart
class AppWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ModularApp.router(title: 'My App');
  }
}
lib/src/app_module.dart
class AppModule extends Module {
  @override
  List<ModularRoute> get routes => [
    ModuleRoute('/', module: HomeModule()),
  ];
}
lib/src/modules/home/home_module.dart
class HomeModule extends Module {
  @override
  FutureBinds binds(Injector i) {
    i.addSingleton<HomeController>((i) => HomeController());
  }
 
  @override
  List<ModularRoute> get routes => [
    ChildRoute('/', child: (context, state) => HomePage()),
  ];
}

Features

FeatureDescription
ModulesEncapsulate routes, dependencies, and logic into self-contained units
Dependency InjectionSingleton, factory, and lazy singleton registration with auto-dispose
Smart RoutingChildRoute, ModuleRoute, ShellRoute, and StatefulShellRoute
Page TransitionsBuilt-in animations via go_transitions (opens in a new tab)
Event SystemDecoupled cross-module communication
Shell RoutesShared layouts with persistent tab state (IndexedStack)

Next Steps