showUpdateDialog static method
Implementation
static void showUpdateDialog(BuildContext context, String url) {
if (Platform.isIOS) {
showCupertinoDialog(
context: context,
barrierDismissible: false,
builder: (dialogContext) => CupertinoAlertDialog(
title: const Text("New Update Available"),
content: const Text(
"New update for your app is now available. Please update the app to continue.",
),
actions: <Widget>[
CupertinoDialogAction(
child: const Text("Update Now"),
onPressed: () {
try { launchUrl(Uri.parse(url)); } catch (_) {}
},
),
],
),
);
} else {
showDialog(
context: context,
barrierDismissible: false,
builder: (dialogContext) {
final isDark = Theme.of(dialogContext).brightness == Brightness.dark;
final bgColor = isDark ? const Color(0xFF1E1E1E) : Colors.white;
final titleColor = isDark ? Colors.white : Colors.black87;
final contentColor = isDark ? Colors.white70 : Colors.black54;
return AlertDialog(
backgroundColor: bgColor,
surfaceTintColor: Colors.transparent,
elevation: 10,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
icon: const Icon(Icons.system_update_rounded, size: 60, color: Colors.blueAccent),
title: Text(
"New Update Available",
textAlign: TextAlign.center,
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 22, color: titleColor),
),
content: Text(
"New update for your app is now available. Please update the app to continue.",
textAlign: TextAlign.center,
style: TextStyle(color: contentColor, fontSize: 16),
),
actionsAlignment: MainAxisAlignment.center,
actionsPadding: const EdgeInsets.only(bottom: 20, left: 20, right: 20),
actions: <Widget>[
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blueAccent,
foregroundColor: Colors.white,
minimumSize: const Size(double.infinity, 50),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
),
child: const Text("UPDATE NOW", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
onPressed: () {
try { launchUrl(Uri.parse(url)); } catch (_) {}
},
),
],
);
},
);
}
}