A NestJS-inspired dependency injection framework for Dart, bringing modular architecture and type-safe service management to Dart applications.
- 🏗️ Modular Architecture - Organize code into reusable modules
- 💉 Dependency Injection - Type-safe service resolution with GetIt
- 🔒 Access Control - Services are private by default, must be explicitly exported
- 🔧 Multi-Platform - Works with Flutter, Dart Frog, and pure Dart applications
- 🚦 Module-Based Routing - GoRouter integration with automatic route collection
Package | Version | Description |
---|---|---|
nest_core | Core dependency injection and module system | |
nest_flutter | Flutter integration with GoRouter and provider support | |
nest_frog | Dart Frog backend integration with middleware support |
import 'package:nest_core/nest_core.dart';
class AppModule extends Module {
@override
List<Module> get imports => [CoreModule(), UserModule()];
@override
void providers(Locator locator) {
locator.registerSingleton<UserService>(UserService());
}
@override
List<Type> get exports => [UserService];
}
// Initialize the application
final container = ApplicationContainer();
await container.registerModule(AppModule());
import 'package:flutter/material.dart';
import 'package:nest_flutter/nest_flutter.dart';
void main() {
runApp(
ModularApp(
module: AppModule(),
child: MyApp(),
),
);
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routerConfig: Modular.router((router) {
return GoRouter(
routes: router.configuration.routes,
initialLocation: '/',
);
}),
);
}
}
class UserModule extends Module {
@override
List<RouteBase> get routes => [
GoRoute(
path: '/users',
builder: (context, state) => UserListPage(),
),
];
@override
void providers(Locator locator) {
locator.registerSingleton<UserService>(UserService());
}
}
- Flutter App - Mobile app with modular architecture and GoRouter integration
- Frog Backend - REST API server with dependency injection and middleware
- 📖 Getting Started - Quick introduction to Nest Dart
- 🎯 Core Guide - Dependency injection fundamentals
- 📱 Flutter Guide - Flutter integration and routing
- 🐸 Frog Guide - Dart Frog backend development
- 🔧 API Reference - Complete API documentation
# Install dependencies
dart pub get
# Run tests
melos run test
# Format code
melos run format
This project is licensed under the MIT License - see the LICENSE file for details.