Added mounted check to popups

This commit is contained in:
Felix Kirchner
2025-05-02 11:07:44 +02:00
parent cd6931093e
commit 966179d01d

View File

@@ -85,10 +85,10 @@ class InformationView extends StatelessWidget {
CupertinoButton(
sizeStyle: CupertinoButtonSize.medium,
child: const Text('Spieldaten exportieren'),
onPressed: () async =>
await LocalStorageService.exportJsonFile()
? null
: showCupertinoDialog(
onPressed: () async {
final success = await LocalStorageService.exportJsonFile();
if (!success && context.mounted) {
showCupertinoDialog(
context: context,
builder: (context) => CupertinoAlertDialog(
title: const Text('Fehler'),
@@ -97,18 +97,22 @@ class InformationView extends StatelessWidget {
actions: [
CupertinoDialogAction(
child: const Text('OK'),
onPressed: () =>
Navigator.pop(context),
onPressed: () => Navigator.pop(context),
),
],
))),
),
);
}
},
),
CupertinoButton(
sizeStyle: CupertinoButtonSize.medium,
child: const Text('Spieldaten importieren'),
onPressed: () async => {
await LocalStorageService.importJsonFile()
? null
: showCupertinoDialog(
onPressed: () async {
final success =
await LocalStorageService.importJsonFile();
if (!success && context.mounted) {
showCupertinoDialog(
context: context,
builder: (context) => CupertinoAlertDialog(
title: const Text('Fehler'),
@@ -117,11 +121,11 @@ class InformationView extends StatelessWidget {
actions: [
CupertinoDialogAction(
child: const Text('OK'),
onPressed: () =>
Navigator.pop(context),
onPressed: () => Navigator.pop(context),
),
],
))
));
}
}),
],
),