Skip to main content

smf_get_it 0.4.2 copy "smf_get_it: ^0.4.2" to clipboard
smf_get_it: ^0.4.2 copied to clipboard

The SMF module of dependency injection with get_it for the Flutter app that SMF generates. It registers the services that the modules of the app declare.

example/README.md

Generate a Flutter app with get_it #

get_it is the module of the SMF CLI that provides dependency injection with get_it. Choose it with -m, here together with event_bus, whose service it registers:

dart pub global activate smf_flutter_cli
smf create my_app -m get_it,event_bus --no-input

The modules of the app declare their services, and this module registers them in lib/core/di/dependencies.dart:

Future<void> registerDependencies() async {
  final getIt = GetIt.instance;
  getIt.registerLazySingleton<di0.CommunicationService>(
    () => di0.createCommunicationService(),
  );
}

bootstrap() awaits registerDependencies() before the first frame, and resetDependencies() resets get_it for a test that registers the services again. Only the composition file of a feature takes services, with resolve<T>() of the ServiceLocator of the dependency injection role, which does not name get_it. The rest of the app gets its services as parameters.

Without -m, smf create asks which module provides dependency injection. When a module you chose needs it and get_it is the only module that provides it, smf create adds get_it by itself.

The documentation has more on the get_it module and on services and state.

0
likes
160
points
1k
downloads

Documentation

Documentation
API reference

Publisher

verified publishersaymyframe.com

Weekly Downloads

The SMF module of dependency injection with get_it for the Flutter app that SMF generates. It registers the services that the modules of the app declare.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#flutter #dependency-injection #get-it #service-locator

License

Apache-2.0 (license)

Dependencies

mason, smf_contracts

More

Packages that depend on smf_get_it