/ForceInject

A zero-dependency DI container for Dart, inspired by .NET Core — fast, testable, and modular. This is the Way.

Primary LanguageDartMIT LicenseMIT

🧬 ForceInject

A modular, zero-runtime-dependency Dependency Injection (DI) system for Dart and Flutter — inspired by .NET Core, and built for clean architecture lovers.

This is the Way.

📦 Packages

Package Description
force_inject Core DI container with singleton, transient, and scoped lifetimes. Zero dependencies, pure Dart.
force_inject_flutter Flutter integration helpers like ForceScopeWidget, ForceViewModelBuilder<T>, and more.

🚀 Examples

Explore real-world usage of ForceInject in Dart and Flutter:

  • 🧱 minimal_dart_di
    A minimal Dart CLI app using singleton and transient services.

  • 📱 minimal_flutter_di
    A Flutter app using scoped DI and a ViewModel with ValueNotifier.

  • 📱 scoped_widget_flutter_di
    A Flutter app using ForceScopeWidget and ForceViewModelBuilder DI and a ViewModel.

To run Flutter examples, remember to generate platform folders first:

cd example/minimal_flutter_di
flutter create .
flutter pub get
flutter run

🎯 Goals

  • Zero runtime dependencies in core
  • No mirrors or code generation
  • Explicit constructor-based injection
  • Lifecycle-aware DI (singleton, transient, scoped)
  • Clean, modular architecture for Dart & Flutter apps
  • Flutter integrations that stay optional and unopinionated

🙌 Support & Contributions

Created by @diegomgarcia 🇨🇦
This project is open to contributions — especially companion packages like:

  • forceinject_riverpod
  • forceinject_bloc
  • forceinject_codegen

Support me (@diegomgarcia) with Patreon

Patreon

Or make a donation buying me a coffee:

Buy Me A Coffee

📜 License

MIT License — Free to use, modify, and extend.

May the DI be with you. ⚔️