[英]How to register ObjectBox in GetIt?
How to properly register ObjectBox in GetIt?如何在 GetIt 中正确注册 ObjectBox? I have an error: The argument type 'Type' can't be assigned to the parameter type 'ObjectBox Function()'.
我有一个错误:无法将参数类型“Type”分配给参数类型“ObjectBox Function()”。
final injector = GetIt.instance;
class DependencyInitializer {
DependencyInitializer._();
static void initDependencies() {
injector
//DataBase
..registerLazySingleton<ObjectBox>(ObjectBox);
}
}
You have to pass a function/constructor that returns an instance.您必须传递一个返回实例的函数/构造函数。 Passing 'ObjectBox' itself is just the type.
传递 'ObjectBox' 本身就是类型。
Try this:尝试这个:
locator.registerLazySingletonAsync<ObjectBox>(() => ObjectBox.create());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.