go_router_modular 4.0.0+4
go_router_modular: ^4.0.0+4 copied to clipboard
go_router wrapper with a modular twist dependency injections and automatic dispose
π§© GoRouter Modular π #
Simplifying Flutter development with modular architecture #
GoRouter Modular simplifies Flutter development by implementing a modular architecture with GoRouter for route management π§© and supports per-module dependency injection with auto-dispose π.
Perfect for micro frontends and large-scale applications! π
π Complete Documentation #
β¨ Key Features #
- π§© Modular Architecture - Independent, reusable modules
- π Dependency Injection - Built-in DI with auto-dispose
- π£οΈ GoRouter Integration - Type-safe and declarative navigation
- π Event System - Event-driven communication between modules
- π Performance - Lazy loading and efficient memory management
- π‘οΈ Type Safety - Fully type-safe with compile-time error detection
β‘ Quick Start #
π§© Module Example #
class HomeModule extends Module {
@override
FutureOr<List<Bind<Object>>> binds() => [
Bind.singleton<HomeController>((i) => HomeController()),
];
@override
List<ModularRoute> get routes => [
ChildRoute('/', child: (context, state) => HomePage()),
ChildRoute('/profile', child: (context, state) => ProfilePage()),
];
}
π Event System #
class NotificationModule extends EventModule {
@override
void listen() {
on<ShowNotificationEvent>((event, context) {
if (context != null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(event.message)),
);
}
});
}
}
// Fire event
ModularEvent.fire(ShowNotificationEvent('Hello!'));
π£οΈ Navigation Examples #
Basic Navigation #
// Navigate to a route
context.go('/profile');
// Push a new route
context.push('/settings');
// Go back
context.pop();
Navigation with Parameters #
// Navigate with path parameters
context.go('/user/123');
// Navigate with query parameters
context.go('/search?q=flutter&category=all');
// Navigate with extra data
context.go('/product', extra: {'id': 456, 'name': 'Flutter Book'});
Async Navigation #
ElevatedButton(
onPressed: () async {
// Show loading
ModularLoader.show();
// Perform async operation
await Future.delayed(Duration(seconds: 2));
// Navigate
await context.goAsync('/heavy-page');
// Hide loading
ModularLoader.hide();
},
child: Text('Navigate with Loading'),
),
π Useful Links #
- π Complete Documentation
- π¦ Pub.dev
- π Issues
- β GitHub
π Happy Coding with GoRouter Modular! π #
Transform your Flutter app into a scalable, modular masterpiece β¨
Made with contrib.rocks