[英]How to get the error from Firestore in Flutter
在我的應用程序中,我有一個 Future Builder,等待從 Firestore 獲取數據。 現在,如果發生網絡問題,我想獲取錯誤類型( snapshot.hasError
)以向用戶顯示。
我的未來建造者:
if (snapshot.hasData) {
children = <Widget>[
Container(
child: color == null
? new Container(
child: Html(
data: snapshot.data,
))
: new Container(
child: Html(
data: snapshot.data,
style: {"html": Style(color: Color(color))}),
),
),
];
} else if (snapshot.hasError) {
children = <Widget>[
Icon(
Icons.error_outline,
color: Colors.red,
size: 60,
),
Padding(
padding: const EdgeInsets.only(top: 16),
child: Text(
'Error: ${snapshot.error}',
textAlign: TextAlign.center,
),
)
];
} else {
children = <Widget>[
CircularProgressIndicator(),
];
}
隨意詢問其他信息。 謝謝你的幫助: :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.