injectable
injectable copied to clipboard
Renaming module causes dependency injection to fail in the runtime
When i'm using name FirebaseCrashlyticsLoggerModule
for the module everything works fine.
When i rename it to CrashlyticsLoggerModule
dependency injection fails in the runtime with message
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: GetIt: Object/factory with type LoggerToolsProvider is not registered inside GetIt.
(Did you accidentally do GetIt sl=GetIt.instance(); instead of GetIt sl=GetIt.instance;
LoggerToolsProvider depends on the module. One thing that is changing is the module class name.
@gabrysgab is there a chance there might be more then one class in your project named that?
Nope. Only this one module is named that way.
@gabrysgab what role does LoggerToolsProvider
play in this?
Module provides firebase crashlytics instance to :
@injectable
class FirebaseCrashlyticsLoggerTool extends LoggerTool {
final FirebaseCrashlytics _firebaseCrashlytics;
FirebaseCrashlyticsLoggerTool(this._firebaseCrashlytics);
@override
void addLog(String msg, LogType type, String? name, {Object? e, StackTrace? st}) {
if (type != LogType.debug) {
final logName = name != null ? "[$name] " : "";
var message = "$logName[${type.tag}] $msg";
_firebaseCrashlytics.log(message);
if (type == LogType.error) {
_firebaseCrashlytics.recordError(e ?? msg, st);
}
}
}
}
and then it is injected to LoggerToolsProvider
@LazySingleton(as: LoggerToolsProvider)
class LoggerToolsProviderImpl extends LoggerToolsProvider {
final FirebaseCrashlyticsLoggerTool _firebaseCrashlyticsLoggerTool;
final FirestoreLoggerTool _firestoreLoggerTool;
LoggerToolsProviderImpl(
this._firebaseCrashlyticsLoggerTool,
this._firestoreLoggerTool,
);
@override
List<LoggerTool> get tools => [
_firebaseCrashlyticsLoggerTool,
_firestoreLoggerTool,
];
}
@gabrysgab that is weird, initializing get_it is not throwing any errors?
Just getting that one error that is in my first message.
@Milad-Akarie we also have multi module architecture. You think that this may cause some issues?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions