我试图通过遵循这个由FilledStacks上传的视频来实现堆叠架构。我在使用可注入的发布包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 尽管我正在按照包文档中显示的方式实现包
发布于 2020-08-31 09:40:56
injectable_generator:
flutter packages pub run build_runner build
添加pubspec.yaml $initGetIt
发布于 2022-10-15 15:07:26
在终点站成功运行后
flutter packages pub run build_runner build将生成的文件.config.dart导入您的文件
import 'locator.config.dart';其中我的文件带有命名的定位器,因此生成的文件名为locator.config.dart
https://stackoverflow.com/questions/63370674
复制相似问题