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! 🚀
✨ 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