Timer _timer;
You have to call this show dialog on your button or where you want to call
showDialog(
context: context,
builder: (BuildContext builderContext) {
_timer = Timer(Duration(seconds: 5), () {
Navigator.of(context).pop(); // == First dialog closed
});
return AlertDialog(
title: Text('First Dialog'),
content: SingleChildScrollView(
child: Text('Content'),
),
);
}).then((val) {
if (_timer.isActive) {
_timer.cancel();
}
}).then((value) {
showDialog(
// == Second dialog open
context: context,
builder: (BuildContext context) {
return AlertDialog(
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
Center(child: CircularProgressIndicator()),
Text('Second Dialog')
],
),
);
},
);
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…