I have an AlertDialog popped up just for several seconds and then automatically popped out without do any action buttons. After it popped out, it will be shows another AlertDialog.
How i can do that?
This is my example code:
Initialize Timer For Show Up The First Dialog:
_timerToShowFirstDialog() async {
var duration = const Duration(seconds: 1);
return Timer(duration, () {
_showFirstDialog();
});
}
First Dialog:
_showFirstDialog(){
return showDialog<String>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Show Dialog 1'),
content: Text('Wait a sec'),
);
});
}
Second Dialog:
_showSecondDialog(){
return showDialog<String>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Show Dialog 2'),
content: Text('After the first dialog popped up for several seconds, shows this dialog without any action buttons'),
);
});
}
I was thinking to using setState in the First Dialog to call/return the second one. But, i don't have any idea where to put the code is.
I appreciate for any answers