How to show progress indicator so that it should show for about 15 seconds.Once it pass 15 seconds a button appears at center "try again" with a message at below "no internet connection".
You can add a delay using Future.delayed()
, and to change the widgets in run time, we can use setState()
.
Combining it all together, you can try something like this:
Widget _dialogContent; // Declare this outside the method, globally in the class
// In your method:
_dialogContent = CircularProgressIndicator();
showDialog(
context: context,
builder: (BuildContext context) => Container(
child: AlertDialog(
content: _dialogContent, // The content inside the dialog
)
)
); // Your Dialog
Future.delayed(Duration(seconds: 15)); // Duration to wait
setState((){
_dialogContent = Container(...), // Add your Button to try again and message text in this
})