ioc_widget 2.0.4
ioc_widget: ^2.0.4 copied to clipboard
A simple, flexible, and testable dependency injection (DI) solution for Flutter, inspired by the best of both the Provider and get_it packages. Supports widget-level DI, transient and singleton strate [...]
2.0.1 #
Added & Fixed #
- Added a
valueparameter to bothInjectScopedDependencyandInjectScopedNotifierto allow injecting an external value or notifier instance that will NOT be disposed by the widget. This makes it easy to provide externally managed dependencies for testing or advanced scenarios. - Fixed disposal behavior: If
valueis provided, the widget will not dispose the instance. Ifvalueis not provided, the instance created by the IoC container will be disposed automatically when the widget is removed from the tree.
2.0.0 #
Breaking Changes #
- Renamed
IocConsumerwidget toInjectScopedDependencyfor clarity and to avoid confusion with Provider's Consumer. - Updated all references in the codebase, example app, and tests to use
InjectScopedDependency. - Updated documentation and API references accordingly.
- Added
InjectScopedNotifier<T extends ChangeNotifier>widget for scoped injection of ChangeNotifier.- Automatically rebuilds child widgets when the notifier calls
notifyListeners. - Disposes the notifier when the widget is removed from the tree.
- Ensures the injected notifier is a singleton within the widget scope and changes when the widget is disposed/recreated.
- Automatically rebuilds child widgets when the notifier calls
- Example app updated with a new page demonstrating
InjectScopedNotifierusage and singleton behavior. - Comprehensive widget tests for
InjectScopedNotifier, covering rebuilds, disposal, singleton scope, and instance recreation.
1.0.0 #
Added #
- Initial release of ioc_widget package.
- InjectableWidget for transient dependencies.
- LazySingletonWidget for lazy singleton dependencies.
- MultiIocWidget for grouping multiple dependencies.
- IocConsumer for scoped dependency access in builder context.
- context.get
- Example app demonstrating navigation and all features.
- Comprehensive widget tests for all DI scenarios.
- MIT License file added.
- Complete README documentation and usage guide.