flutter_injections

Last updated:

0 purchases

flutter_injections Image
flutter_injections Images
Add to Cart

Description:

flutter injections

Flutter Injections #
This package helps you to manage any dependencies in your project without need to use context and makes possible to create dependencies for modules. The objective is help any developer to manage dependencies with a easy to use API.
Learn more #
More details on the documentation.
Why Flutter Injections? #

Fast and Efficient

Flutter Injections use search-tree to get the dependencies, this improve the speed to get them, and use less CPU to search for specific objects.


Module Injections

Create module injections that have all dependencies needed on your widgets. I.E HomeInjections have all dependencies needed on HomePage.


Easy to use

The focus is to keep it simple to handle dependencies on large scale applications.


Auto dispose

Objects are auto disposed when FlutterInjection is removed from the Widget Tree.


Simple dispose

With Flutter Injections you can dispose a specific object using __dispose<T> method.



How to use #
It`s simple, just three steps:


Add the FlutterInjections to pubspec.yaml file
flutter_injections: ^any # or current version
copied to clipboard


Create your FlutterInjections anywhere you to need.
class YourPageInjections extends StatelessWidget {
const YourPageInjections({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return FlutterInjectionsWidget(injections: [
Inject<YourRepository>((i) => YourRepository(client: i.find<Dio>())),
Inject<YourController>(
(i) => YourController(repository: i.find<YourRepository>())),
], builder:(_) => const YourPage());
}
}
copied to clipboard
Or you can use extends the new widget FlutterModule to add your dependencies
class YourModule extends FlutterModule {
const YourModule({Key? key}) : super(key: key);

@override
Widget get child => const YourPage();

@override
List<Inject<Object>> get injections => [
Inject<YourRepository>((i) => YourRepository(client: i.find<Dio>())),
Inject<YourController>(
(i) => YourController(repository: i.find<YourRepository>())),
];
}

copied to clipboard


And finally, use it to get the dependencies:
final controller = FlutterInjections.get<YourController>();
copied to clipboard



Direct and simple! Good job and have fun!

Contribuitors #
Be a contribuitor too!



Made with contrib.rocks.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.