openSaveBeforeLeavingDialog method
- BuildContext context, {
- String? title,
- bool unfocus = true,
Opens a confirmation dialog about saving the changes before leaving.
Returned values:
nullmeans the user's dismissed the dialog and doesn't want to leave.truemeans the user wants to save the changes and leave.falsemeans the user wants to ignore the changes and leave.
Implementation
Future<bool?> openSaveBeforeLeavingDialog(
BuildContext context, {
String? title,
bool unfocus = true,
}) async {
if (unfocus) {
FocusManager.instance.primaryFocus?.unfocus();
}
final AppLocalizations appLocalizations = AppLocalizations.of(context);
final SmoothColorsThemeExtension extension = context
.extension<SmoothColorsThemeExtension>();
return showSmoothAlertModalSheet<bool>(
context: context,
title: title ?? appLocalizations.edit_product_form_item_exit_title,
message: Text(appLocalizations.edit_product_form_item_exit_confirmation),
type: SmoothModalSheetType.error,
actionLabels: <String>[
appLocalizations
.edit_product_form_item_exit_confirmation_positive_button,
appLocalizations
.edit_product_form_item_exit_confirmation_negative_button,
],
actionIcons: <Widget>[
Icon(Icons.save_rounded, color: extension.success),
Icon(Icons.cancel_rounded, color: extension.error),
],
actionValues: <bool>[true, false],
);
}