1

我使用此方法将我的 ObjectBox Store 注册为 LazySingleton

setupLocatorAdditions() async {
  stackedAdditionLocator.registerLazySingletonAsync<Store>(() => openStore());
}

效果很好。但是在从 BuildRunner 多次重建之后,ObjectBox Generator 抛出了这个错误,不管我是否删除了单例注册并重新运行它。

lib/objectbox.g.dart:1341:67: Error: No named parameter with the name 'lazy'.
              weekDays: const fb.ListReader<int>(fb.Int8Reader(), lazy: false)
                                                                  ^^^^
../../Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/objectbox-1.1.1/lib/flatbuffers/flat_buffers.dart:994:9: Context: Found this candidate, but the arguments don't match.
  const ListReader(this._elementReader);
        ^^^^^^^^^^

lib/objectbox.g.dart:1343:68: Error: No named parameter with the name 'lazy'.
              locations: const fb.ListReader<int>(fb.Int8Reader(), lazy: false)
                                                                   ^^^^
../../Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/objectbox-1.1.1/lib/flatbuffers/flat_buffers.dart:994:9: Context: Found this candidate, but the arguments don't match.

  const ListReader(this._elementReader);
        ^^^^^^^^^^
2

FAILURE: Build failed with an exception.

4

1 回答 1

1

该参数不是已发布的 objectbox-dart v1.1.1 的一部分(它是在13 天前由此提交添加的,而 v1.1.1 是 19 天前发布的)。

看起来您使用的是不匹配的生成器?你能检查一下你pubspec.yaml是否在 objectbox_generator 上使用依赖项覆盖,例如来自 git 吗?如果你使用依赖覆盖,你应该坚持一个特定的提交,并确保你在生成器和 objectbox 库本身上都使用它。如果您不需要依赖项覆盖,只需将其从pubspec.yaml.

在这两种情况下,pub get在进行更改后运行pub run build_runner build.

于 2021-07-28T07:11:40.050 回答