registerCore method
void
registerCore()
Registers core dependencies if they haven't been registered yet.
CommonBloc is registered as a lazy singleton: it holds app-wide
loading state, so every page must observe the same instance. A factory
registration hands each caller its own instance, and a showLoading() on
one is invisible to the widget rendering another.
This is the only registration path for CommonBloc. It is deliberately
not an @module — injectable's code generator does not scan modules
declared inside a package, only those in the consuming app, so a
module here would never appear in a consumer's generated config.
Example:
void configureInjectionApp() {
getIt.registerCore();
}
Implementation
void registerCore() {
try {
if (!isRegistered<CommonBloc>()) {
registerLazySingleton<CommonBloc>(CommonBloc.new);
}
} catch (e) {
throw DependencyRegistrationException(
'Failed to register core dependencies',
e,
);
}
}