Hello I am trying to show Snackbar if network response return error right now My Build function looks like this:
@override
Widget build(BuildContext context) {
NewsBloc bloc = NewsBloc();
return Scaffold(
key: scaffoldKey,
body: Container(
color: Colors.white,
child: StreamBuilder<List<BaseModel>>(
stream: bloc.newsStream,
builder: (BuildContext context, AsyncSnapshot<List<BaseModel>> snap) {
if (snap.hasError) {
scaffoldKey.currentState.showSnackBar(SnackBar(
content: Container(
height: 100,
),
));
return Center(child: Text(snap.error));
} else if (!snap.hasData) {
return Center(child: CircularProgressIndicator());
} else {
return _newsList(snap.data);
}
},
),
),
);
}
It shows the Snackbar but also throws an error:
This Scaffold widget cannot be marked as needing to build
because the framework is already in the procces