简体   繁体   English

Stream 构建器在使用 Firestore 发布的 flutter 应用程序上返回 null

[英]Stream builder returns null on released flutter app using firestore

StreamBuilder widget works well on debug mode but on release mode returns null . StreamBuilder小部件在调试模式下运行良好,但在发布模式下返回null I had tried several solutions found here, but none worked.我尝试了这里找到的几种解决方案,但都没有奏效。 So maybe I am missing something in my code.所以也许我在我的代码中遗漏了一些东西。 Here are my source codes.这是我的源代码。

store_screen.dart store_screen.dart

StreamBuilder<List<StoreItem>>(
  initialData: [],
  stream: widget.bloc.getStores(),
  builder: (context, querySnapshot) {
    if (querySnapshot.connectionState == ConnectionState.active) {
      List<StoreItem> stores = querySnapshot.data!;
      ....
    } else if (querySnapshot.hasError) {
      print(querySnapshot.toString());
      ....
    } else {
      ....
      return Center(
        child: CircularProgressIndicator(),
      );
    }
  },
),

store_bloc.dart store_bloc.dart

Stream<List<StoreItem>> getStores() {
  final snapshot = database.getDataFromCollection('owner');

  return snapshot.map((event) => event.docs
      .map((e) => StoreItem.fromMap(e.data() as Map<String, dynamic>))
      .toList());
}

If it works perfectly on debug mode, but failing only on release version, then it can be because of you didn't add app hash code on firebase config.如果它在调试模式下完美运行,但仅在发布版本上失败,那么可能是因为您没有在 firebase 配置上添加应用程序 hash 代码。 Also I suggest to check privacy rules of database and make it properly for production.另外我建议检查数据库的隐私规则并使其适合生产。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM