English 中文(简体)
精简建筑和消防数据库
原标题:StreamBuilder and Firestore database

I am was building a flutter application with some Sqflite and firestore database Now I have ran into a problem that whenever I run the application. I get snapshot.hasdata to true for the first time and than I get snapshot.hasdata to false in a second. I am attaching the screenshots of both console and the code here

StreamBuilder(
  stream: FirebaseFirestore.instance
      .collection( ADs CommonGroup )
      .orderBy("id", descending: true)
      .orderBy("id", descending: true)
      .where( id , isEqualTo: databaseLogin[0]["number"])
      .snapshots(),
  builder: (
    BuildContext context,
    AsyncSnapshot<QuerySnapshot> snapshot,
  ) {
    print( snapshot does not have data ${snapshot.hasData} );
    print(databaseLogin[0]["number"]);

如今,这本小册子已经出版。

I/flutter (16812): snapshot does not have data false
I/flutter (16812): +923335885631
I/flutter (16812): snapshot does not have data true
I/flutter (16812): +923335885631
I/flutter (16812): snapshot does not have data false
I/flutter (16812): +923335885631

What can I do code with Console

我想到的是头痛。 如果有数据,数据应当恢复到以前一样的水平。

问题回答

采用<代码>AsyncSnapshot的第一步是处理错误。 简单:

builder: (
  BuildContext context,
  AsyncSnapshot<QuerySnapshot> snapshot,
) {
  if (snapshot.hasError) {
    print(snapshot.error);
    return Text("ERROR: ${snapshot.error}");
  }
  print( snapshot does not have data ${snapshot.hasData} );
  print(databaseLogin[0]["number"]);
  ...

这可能告诉你问题的原因。





相关问题
Flutter App cannot be installed on Android TV

I m building a Flutter app that should support Android TV and Mobile devices. Despite Google Play shows that it is supported, I cannot install app on my MiBox device. While trying to install it, both ...

Moving the icon button to the right causes rendering issues

I am trying to align the icon button to the right of the Text field, I tried the row which made the icon button not centered vertically and now I am trying out the Stack widget. Here is my code - ...

热门标签