Skip to content

Instantly share code, notes, and snippets.

@vijayinyoutube
Created July 21, 2022 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijayinyoutube/54dde659435efbfb7aa421fd6725e49d to your computer and use it in GitHub Desktop.
Save vijayinyoutube/54dde659435efbfb7aa421fd6725e49d to your computer and use it in GitHub Desktop.
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