我正在尝试按照 FilledStacks 上传的这个视频来实现堆叠架构。
我在使用可注入(inject)的 pub 包时遇到问题
https://pub.dev/packages/injectable
我的 locator.dart 类代码如下
import 'package:get_it/get_it.dart';
import 'package:injectable/injectable.dart';
final locator = GetIt.instance;
@injectableInit
void setupLocator() => $initGetIt(locator);
在 $initGetIt(locator)
我收到此错误The function '$initGetIt' isn't defined.
Try importing the library that defines '$initGetIt', correcting the name to the name of an existing function, or defining a function named
即使我正在按照包文档中显示的方式实现包https://www.youtube.com/watch?v=DO8le1W_HqQ&t=914s
最佳答案
injectable_generator:
flutter packages pub run build_runner build
$initGetIt
来自生成的文件 关于flutter - 使用可注入(inject) pub 包时未定义函数 '$initGetIt',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63370674/