In my app, I have a Future Builder, waiting for fetched Data from Firestore. Now I want to get the error type ( snapshot.hasError
) to show the user, if a network problem occured.
My FutureBuilder:
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(),
];
}
Fell free to ask for additional Information. Thanks for your help: :)
I have found two issues ( 1 and 2 ) reporting this on GitHub that have been merged into a single issue . In a comment it is explained that this issue has already been solved and merged into the master
branch. As per this comment it was pre-released on the 14th of July.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.