小编w46*_*461的帖子

flutter:如何使用“await for”等待其他 BLoC 事件完成

在屏幕初始化上,我通过 externalData_bloc 加载数据。在同一屏幕上,我还渲染了另一个由internalData_bloc控制的小部件,用于用户输入,这取决于导入记录的数量(需要多少行)。当然,渲染速度比数据加载速度快,因此我得到了所需的空行。

我发现了这个很好的问题和答案,但是,我无法让它发挥作用。解决方案说

Future loginProcess() async {
  await for (var result in _userBloc.state) {
    if (result.status == Status.finished) {
      return;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我在我的存储库中。在这里,我还将外部数据存储在变量中。因此,在存储库类中,我有函数来获取记录数(properties存储在存储库中,我想返回其长度)。

  Future<int> getNoOfProperties(int problem)  async {
    LogicGraphsPStmntBloc bloc = LogicGraphsPStmntBloc();
    Future propertiesLoad() async {
      await for (var s in bloc) {
        if (s == LogicGraphsPStmntLoadSuccess) {
          return;
        }
      }
    }
    propertiesLoad();
    return properties.length;
  }
Run Code Online (Sandbox Code Playgroud)

await for (var result in XXXX)但无论我尝试为or投入什么if (s.YYY == ZZZ),它都不起作用。我的理解是, XXXX 需要是一个流,这就是我使用bloc = LogicGraphsPStmntBloc(). …

state async-await flutter bloc

5
推荐指数
1
解决办法
3268
查看次数

严重的injectable_generator:injectable_builder ...类型“UnspecifiedInvalidResult”不是类型转换中“LibraryElementResult”类型的子类型

当重构我的代码和执行 build_runner 时,我突然收到了类似的错误

[SEVERE] injectable_generator:injectable_builder on lib/application/authorization/xxx data_sync/sync_data.dart (cached):

type 'UnspecifiedInvalidResult' is not a subtype of type 'LibraryElementResult' in type cast
Run Code Online (Sandbox Code Playgroud)

可以看出,它们是由注射包产生的。

flutter build-runner

5
推荐指数
2
解决办法
2260
查看次数

flutter:使用 Float64List Matrix4 变换 CustomPaint 中的路径

我试图旋转一些路径,但没有找到片段,并且一般来说,matrix4 没有很好的记录。因此,如果其他人遇到此问题,这就是我的最终结果

graphics flutter flutter-layout

1
推荐指数
1
解决办法
2087
查看次数