shovel 1.0.0+2
shovel: ^1.0.0+2 copied to clipboard
A lightweight dependency injection framework for Dart applications that provides an intuitive way to manage dependencies.
Shovel #
A lightweight dependency injection framework for Dart applications that provides an intuitive way to manage dependencies. Shovel is inspired by Kodein, a dependency injection library for Kotlin.
Features #
- Simple and intuitive API for dependency registration and resolution
- Support for parameterized dependency injection
- Ability to merge multiple dependency containers
- Type-safe dependency resolution
- Flexible dependency configuration
Getting Started #
Add shovel to your pubspec.yaml:
dependencies:
shovel: ^1.0.0
Usage #
Here's a basic example of how to use Shovel:
// Define your classes
class UserService {
final String apiKey;
UserService({required this.apiKey});
}
class UserRepository {
final UserService userService;
UserRepository(this.userService);
}
// Set up dependency injection
final ground = Ground()
..buryWithArg<UserService, String>((shovel, apiKey) => UserService(apiKey: apiKey))
..bury<UserRepository>((shovel) => UserRepository(
shovel.digWithArg<UserService, String>('your-api-key'),
));
// Get instances
final shovel = ground.shovel();
final repository = shovel.dig<UserRepository>();
For more complex examples, check the /example folder.
Additional Information #
- Package is compatible with Dart SDK 3.6.0 or higher
- For bug reports and feature requests, please visit the issue tracker
- Contributions are welcome!