flutter_injections 1.1.1 copy "flutter_injections: ^1.1.1" to clipboard
flutter_injections: ^1.1.1 copied to clipboard

Elevate your project's dependency management with this versatile Flutter package. Say goodbye to the limitations of context and unlock the ability to seamlessly create dependencies for modules. Simpli [...]

codecov

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:

  1. Add the FlutterInjections to pubspec.yaml file

    flutter_injections: ^any # or current version
    
  2. 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());
      }
    }
    

    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>())),
        ];
    }
    
    
  3. And finally, use it to get the dependencies:

    final controller = FlutterInjections.get<YourController>();
    
  • Direct and simple! Good job and have fun!

Contribuitors #

Be a contribuitor too!

Made with contrib.rocks.

20
likes
150
pub points
49%
popularity

Publisher

verified publishergabul.dev

Elevate your project's dependency management with this versatile Flutter package. Say goodbye to the limitations of context and unlock the ability to seamlessly create dependencies for modules. Simplify your project's structure and enhance your development process with this powerful tool

Homepage
Repository (GitHub)
View/report issues

Topics

#dependency #di #injection

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_injections