Skip to main content

How to use

You need to add FlutterInjections widget before your Page. See below example.

class YourPageInjections extends StatelessWidget {
const YourPageInjections({Key? key}) : super(key: key);


Widget build(BuildContext context) {
return FlutterInjections(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);


Widget get child => const HomePage();


List<Inject<Object>> get injections => [
Inject<HomeRepository>((i) => HomeRepository(client: i.find<Dio>())),
Inject<HomeController>(
(i) => HomeController(repository: i.find<HomeRepository>())),
];
}

caution

You need pass the type on Inject<\T> of object inject.