showRequiredUpdateAlertDialog method
void
showRequiredUpdateAlertDialog({
- required BuildContext context,
- required AppVersionStatus appVersionStatus,
- String alertTitle = 'Update Available',
- String? alertText,
- String updateBtn = 'Update',
- bool allowDismissible = false,
- VoidCallback? dismissAction,
Implementation
void showRequiredUpdateAlertDialog(
{required BuildContext context,
required AppVersionStatus appVersionStatus,
String alertTitle = 'Update Available',
String? alertText,
String updateBtn = 'Update',
bool allowDismissible = false,
VoidCallback? dismissAction}) async {
final alertTitleWidget = Text(alertTitle);
final alertTextWidget =
Text(alertText ?? 'Please update the app to continue');
final updateBtnTxtWidget = Text(updateBtn);
final updateAction = () {
_launchAppStore(appVersionStatus.appStoreLink);
};
List<Widget> actions = [
Platform.isAndroid
? TextButton(
child: updateBtnTxtWidget,
onPressed: updateAction,
)
: CupertinoDialogAction(
child: updateBtnTxtWidget,
onPressed: updateAction,
),
];
showDialog(
context: context,
barrierDismissible: allowDismissible,
builder: (BuildContext context) {
return WillPopScope(
child: Platform.isAndroid
? AlertDialog(
title: alertTitleWidget,
content: alertTextWidget,
actions: actions,
)
: CupertinoAlertDialog(
title: alertTitleWidget,
content: alertTextWidget,
actions: actions,
),
onWillPop: () => Future.value(allowDismissible));
},
);
}