Keyboard Shortcuts

j / kScroll down / up
ggScroll to top
GScroll to bottom
/Open search
?Show this help
EscClose search / help
n / NNext / previous section
hGo to landing
dGo to docs
:Command mode — type section name

Press ? or Esc to close

Architecture

Dependency Injection

Core services registered once at bootstrap. Feature DI is lazy — registered on route entry, unregistered on pop.

Core services — bootstrap only

// app/app_bootstrap.dart
void bootstrap() {
  sl.registerSingleton(ApiClient());
  sl.registerSingleton(AppDatabase());
  sl.registerLazySingleton(() => GlobalErrorCubit());
  sl.registerLazySingleton(() => ThemeCubit());
  sl.registerLazySingleton(() => LocalizationCubit(sl()));
}

Feature DI — lazy, scoped to route lifetime

// features/profile/config/profile_di.dart
void registerProfileDependencies() {
  sl.registerLazySingleton(() => ProfileDataSource(sl()));
  sl.registerLazySingleton(() => ProfileLocal(sl()));
  sl.registerLazySingleton(() => ProfileStore(sl(), sl()));
  sl.registerFactory(() => ProfileCubit(sl()));
}

void unregisterProfileDependencies() {
  sl.unregister();
  sl.unregister();
  sl.unregister();
}
ReasonBenefit
Faster startupNothing created until the feature is actually entered
Lower memoryDependencies destroyed when the user leaves the feature
True isolationNo feature can depend on another's internals
sam's arch — A Pragmatic Flutter Architecture