Created
July 21, 2022 18:45
-
-
Save vijayinyoutube/54dde659435efbfb7aa421fd6725e49d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
showDialogBox() => showCupertinoDialog<String>( | |
context: context, | |
builder: (BuildContext context) => CupertinoAlertDialog( | |
title: const Text('No Connection'), | |
content: const Text('Please check your internet connectivity'), | |
actions: <Widget>[ | |
TextButton( | |
onPressed: () async { | |
Navigator.pop(context, 'Cancel'); | |
setState(() => isAlertSet = false); | |
isDeviceConnected = | |
await InternetConnectionChecker().hasConnection; | |
if (!isDeviceConnected && isAlertSet == false) { | |
showDialogBox(); | |
setState(() => isAlertSet = true); | |
} | |
}, | |
child: const Text('OK'), | |
), | |
], | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment