I have made a dialog appear which can be closed if someone correctly types in a certain word. I wanted to know if it was possible to make a second dialog appear if someone does not type anything into the first text box within a certain timeframe. For example, if the person does not input text within the next 5 minutes, is there any way to trigger a second dialog to show up?
Future.delayed(Duration(seconds: 5), () {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) {
return AlertDialog(
title: Text('Your time finished'),
content: Text('Type "OKAY" if you want to go back to the homepage'),
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: TextFormField(
controller: _textEditingController,
validator: (String? word){
if (word != OKAY){
_NoDialog();
}
else{
Navigator.pop(context);
}
},
),
),
],
);
});
});
I called the function NoDialog
if the text the person gives is incorrect, but I am not sure how to make an 'if' statement if the person does not put anything in the text box for a certain period of time.
I think I could do an 'if' statement if the person leaves the text blank and then call a new function with a Future.delayed attached, but I couldnt find a way to make an 'if' statement for the case when no text is entered. Also in this case, I believe the person would have to hit the 'enter' key, but I want the second dialog to show up because the user has not touched anything on the screen. Is this possible?