Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud firestore 使用颤振和Firestore显示特定数据_Google Cloud Firestore_Flutter - Fatal编程技术网

Google cloud firestore 使用颤振和Firestore显示特定数据

Google cloud firestore 使用颤振和Firestore显示特定数据,google-cloud-firestore,flutter,Google Cloud Firestore,Flutter,我目前正在使用此代码映射整个todo任务列表: return new StreamBuilder<QuerySnapshot>( stream: Firestore.instance.collection('todo_list').snapshots, builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) { if (!snapshot.hasData) return

我目前正在使用此代码映射整个todo任务列表:

return new StreamBuilder<QuerySnapshot>(
  stream: Firestore.instance.collection('todo_list').snapshots,
  builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
    if (!snapshot.hasData) return new Text('Loading...');
    return new ListView(
      children: snapshot.data.documents.map((DocumentSnapshot document) {
        document['status'] == true ?
        new ListTile(
          title: new Row(
            children: <Widget>[
              new Expanded(
                child: new Text(document['task'], 
                style: new TextStyle(
                  decoration: TextDecoration.lineThrough,
                  ),
                ),
              )
            ],
          )
        ) : new Text("");
      }).toList(),
    );
  },
);
返回新的StreamBuilder(
流:Firestore.instance.collection('todo_list')。快照,
生成器:(BuildContext上下文,异步快照){
如果(!snapshot.hasData)返回新文本('Loading…');
返回新的ListView(
子项:snapshot.data.documents.map((DocumentSnapshot文档){
文档['status']==true?
新ListTile(
标题:新行(
儿童:[
新扩展(
子项:新文本(文档['task'],
样式:新文本样式(
装饰:textEdition.lineThrough,
),
),
)
],
)
):新文本(“”);
}).toList(),
);
},
);
我想显示状态为true的任务。但是,执行此操作时会出现错误:

I/flutter (21800): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (21800): The following assertion was thrown during performLayout():
I/flutter (21800): 'package:flutter/src/widgets/sliver.dart': Failed assertion: line 291 pos 12: 'child != null': is
I/flutter (21800): not true.
I/flutter (21800):
I/flutter (21800): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (21800): more information in this error message to help you determine and fix the underlying cause.
I/flutter (21800): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (21800):   https://github.com/flutter/flutter/issues/new
I/flutter (21800):
I/flutter (21800): When the exception was thrown, this was the stack:
I/flutter (21800): #2      SliverChildListDelegate.build (package:flutter/src/widgets/sliver.dart)
I/flutter (21800): #3      SliverMultiBoxAdaptorElement._build.<anonymous closure> (package:flutter/src/widgets/sliver.dart:716:67)
I/flutter (21800): #4      _HashMap.putIfAbsent 
I/颤振(21800):══╡ 呈现库捕获到异常╞═════════════════════════════════════════════════════════
I/flatter(21800):在performLayout()期间抛出了以下断言:
I/flatter(21800):'package:flatter/src/widgets/sliver.dart':失败的断言:第291行位置12:'child!=空“:是
I/颤振(21800):不正确。
I/颤振(21800):
I/flatter(21800):要么断言表明框架本身存在错误,要么我们应该提供
I/flatter(21800):此错误消息中的更多信息可帮助您确定和修复根本原因。
I/flatter(21800):无论哪种情况,请在GitHub上提交一个bug来报告这一断言:
I/颤振(21800):https://github.com/flutter/flutter/issues/new
I/颤振(21800):
I/flatter(21800):抛出异常时,这是堆栈:
I/flatter(21800):#2 SliverChildListDelegate.build(包:flatter/src/widgets/sliver.dart)
I/颤振(21800):#3个SliverMultiboxAdapterElement.U构建。(包装:颤振/src/widgets/silver.dart:716:67)
I/颤振(21800):#4#HashMap.putIfAbsent


有什么建议吗?

您忘了返回三元计算的实际结果

return  document['status'] == true ?
    ....

这应该可以解决问题

我找到了解决办法:

Firestore.instance.collection('todo_list').where('status', isEqualTo: false).snapshots,

您可以使用firestore代码进行查询。

您可以发布实际错误吗?完成。如果你需要完整的代码,hmu。错误比这个长得多。非常感谢!