action method
- BuildContext context
override
Implementation
@override
Future<void> action(BuildContext context) async {
final AppLocalizations appLocalizations = AppLocalizations.of(context);
if (!await ProductRefresher().checkIfLoggedIn(
context,
isLoggedInMandatory: isLoggedInMandatory,
)) {
return;
}
if (!context.mounted) {
return;
}
final bool? confirmed = await showDialog<bool>(
context: context,
builder: (BuildContext context) {
return SmoothAlertDialog(
title: appLocalizations.confirm_button_label,
body: Text(appLocalizations.are_you_sure),
close: true,
positiveAction: SmoothActionButton(
text: appLocalizations.yes,
onPressed: () => Navigator.of(context).pop(true),
),
negativeAction: SmoothActionButton(
text: appLocalizations.no,
onPressed: () => Navigator.of(context).pop(false),
),
);
},
);
if (confirmed != true) {
return;
}
if (!context.mounted) {
return;
}
final LocalDatabase localDatabase = context.read<LocalDatabase>();
await BackgroundTaskUnselect.addTask(
barcode,
imageField: imageField,
context: context,
language: language,
productType: productType,
);
localDatabase.notifyListeners();
if (!context.mounted) {
return;
}
Navigator.of(context).pop();
}