【发布时间】:2018-10-22 13:54:56
【问题描述】:
我目前正在使用此代码来映射整个待办事项列表:
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(),
);
},
);
我想显示状态为真的任务。但是,这样做时会出现错误:
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
...
有什么建议吗?
【问题讨论】:
-
你能发布实际的错误吗?
-
完成。如果您需要整个代码,hmu。错误比这长得多。
标签: google-cloud-firestore flutter