force_inject_provider 0.1.0 copy "force_inject_provider: ^0.1.0" to clipboard
force_inject_provider: ^0.1.0 copied to clipboard

Provider integration for ForceInject — a lightweight dependency injection container for Dart and Flutter.

🧩 force_inject_provider #

A plugin that integrates the ForceInject DI container with the popular Provider package in Flutter.

🛠️ Easily create scoped dependency injection and reactive ChangeNotifier ViewModels.

✨ Features #

  • ✔️ ProviderScope to manage lifecycle-aware DI scopes
  • ✔️ ProviderNotifierBuilder<T> to inject and listen to ChangeNotifiers
  • ✔️ Automatically disposes ViewModels
  • ✔️ Clean integration with force_inject

🚀 Getting Started #

1. Define your services: #

final services = ServiceCollection();
services.addScoped<CounterViewModel, CounterViewModel>();

ServiceProvider.registerConstructor<CounterViewModel>(
  () => CounterViewModel(),
  [],
);

final provider = services.buildServiceProvider();

2. Wrap your app or page in a ProviderScope: #

return ProviderScope(
  create: () => provider.createScope(),
  child: MyApp(),
);

3. Use ProviderNotifierBuilder<T> to inject your ViewModel: #

ProviderNotifierBuilder<CounterViewModel>(
  builder: (context, viewModel, _) => Text('${viewModel.count}'),
)

📦 Example #

See example/minimal_provider_di for a full working Flutter app.

📜 License #

MIT — Free to use, modify, and distribute.

1
likes
140
points
29
downloads

Publisher

verified publisherdiegogarcia.ca

Weekly Downloads

Provider integration for ForceInject — a lightweight dependency injection container for Dart and Flutter.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, force_inject, provider

More

Packages that depend on force_inject_provider