I'm using Firebase with Flutter. After I retrieve documents as a contents list, I don't know how to handling screen. The code is in StreamBuilder. I would like to show dialog at first, and after push dialog OK button, navigate the other next screen.
How ever following code does not navigate next screen.
final List<DocumentSnapshot> contents = snapshot.data.documents;
if (contents.length == 0) {
try {
print('NO DATA FOR THIS USER. ${contents.length}');
showDialog(
context: context,
builder: (_) {
return AlertDialog(
title: Text('Error'),
content: Text('Please Register First.'),
actions: <Widget>[
FlatButton(
child: Text('OK'),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => NextPage()));
//Navigator.pop(context);
},
),
],
);
});
} catch (e) {
return Container();
}
}
If I don't return Container, Error screen show up.