showNetworkErrorDialog static method
Implementation
static void showNetworkErrorDialog(BuildContext context, VoidCallback retryFetch) {
if (Platform.isIOS) {
showCupertinoDialog(
context: context,
barrierDismissible: false,
builder: (dialogContext) => CupertinoAlertDialog(
title: const Text("Network Issue"),
content: const Text(
"Slow internet or network error. Please check your connection and try again.",
),
actions: <Widget>[
CupertinoDialogAction(
child: const Text("Retry"),
onPressed: () {
Navigator.pop(dialogContext);
retryFetch();
},
),
],
),
);
} else {
showDialog(
context: context,
barrierDismissible: false,
builder: (dialogContext) => AlertDialog(
backgroundColor: Colors.white,
surfaceTintColor: Colors.transparent,
elevation: 10,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
icon: const Icon(Icons.wifi_off_rounded, size: 60, color: Colors.redAccent),
title: const Text("Network Issue", textAlign: TextAlign.center, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22, color: Colors.black87)),
content: const Text(
"Slow internet or network error. Please check your connection and try again.",
textAlign: TextAlign.center,
style: TextStyle(color: Colors.black54, fontSize: 16),
),
actionsAlignment: MainAxisAlignment.center,
actionsPadding: const EdgeInsets.only(bottom: 20, left: 20, right: 20),
actions: <Widget>[
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.redAccent,
foregroundColor: Colors.white,
minimumSize: const Size(double.infinity, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
),
),
child: const Text("RETRY", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
onPressed: () {
Navigator.pop(dialogContext);
retryFetch();
},
),
],
),
);
}
}