【发布时间】:2021-05-05 02:32:28
【问题描述】:
我尝试在构造函数中将查询从第一页传递到第二页
Navigator.push(context, MaterialPageRoute(builder: (context) => ListWisataScreen(querySnapshot: dataService.getAllWisata(),)))
查询成功通过,数据显示出来,但只有一半,其他数据跟随错误
Bad state: field does not exist within the DocumentSnapshotPlatform
这里是错误screenshoot
这是第二页代码
FutureBuilder<QuerySnapshot>(
future: querySnapshot,
builder: (context, snapshot) {
if(!snapshot.hasData || snapshot.connectionState == ConnectionState.waiting) {
return Center(child: CircularProgressIndicator(strokeWidth: 3,),);
} else if(snapshot.connectionState == ConnectionState.done && snapshot.hasData){
return ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: snapshot.data.docs.length,
itemBuilder: (context, index) {
var doc = snapshot.data.docs[index];
return ListTile(...);
}
);
} else if(snapshot.connectionState == ConnectionState.none) {
return Text("Tidak Ada Data");
} else {
return Text("Cek Koneksi Internet");
}
}
)
【问题讨论】:
标签: firebase flutter dart google-cloud-firestore flutter-futurebuilder