我的窗戶上有顫振(v2.8.1)的問題。
我正在嘗試使用 StreamBuilder 類從 firebase 獲取資料,但它無論如何都不起作用。我嘗試使用 BuildContext 背景關系,但它仍然在背景關系中拋出錯誤。
請看看我的代碼,讓我知道我做錯了什么。答案表示贊賞。提前致謝。
StreamBuilder(builder: (BuildContext context, snapshot), stream: _firestore.collection('messages').snapshots()),
錯誤 :
引數型別“Type”不能分配給引數型別“Widget Function(BuildContext, AsyncSnapshot<QuerySnapshot<Map<String, dynamic>>>)”。
請查看圖片:https : //imgur.com/a/QJs6hS9
uj5u.com熱心網友回復:
builder 引數應該是一個回傳小部件的函式。
builder: (context, snapshot) {
// return a widget that uses the snapshot
// for example
return Text(snapshot.data().title);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/408742.html
標籤:
