Added mounted check to popups
This commit is contained in:
@@ -83,46 +83,50 @@ class InformationView extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
CupertinoButton(
|
CupertinoButton(
|
||||||
sizeStyle: CupertinoButtonSize.medium,
|
sizeStyle: CupertinoButtonSize.medium,
|
||||||
child: const Text('Spieldaten exportieren'),
|
child: const Text('Spieldaten exportieren'),
|
||||||
onPressed: () async =>
|
onPressed: () async {
|
||||||
await LocalStorageService.exportJsonFile()
|
final success = await LocalStorageService.exportJsonFile();
|
||||||
? null
|
if (!success && context.mounted) {
|
||||||
: showCupertinoDialog(
|
showCupertinoDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => CupertinoAlertDialog(
|
builder: (context) => CupertinoAlertDialog(
|
||||||
title: const Text('Fehler'),
|
title: const Text('Fehler'),
|
||||||
content: const Text(
|
content: const Text(
|
||||||
'Datei konnte nicht exportiert werden.'),
|
'Datei konnte nicht exportiert werden.'),
|
||||||
actions: [
|
actions: [
|
||||||
CupertinoDialogAction(
|
CupertinoDialogAction(
|
||||||
child: const Text('OK'),
|
child: const Text('OK'),
|
||||||
onPressed: () =>
|
onPressed: () => Navigator.pop(context),
|
||||||
Navigator.pop(context),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
))),
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
CupertinoButton(
|
CupertinoButton(
|
||||||
sizeStyle: CupertinoButtonSize.medium,
|
sizeStyle: CupertinoButtonSize.medium,
|
||||||
child: const Text('Spieldaten importieren'),
|
child: const Text('Spieldaten importieren'),
|
||||||
onPressed: () async => {
|
onPressed: () async {
|
||||||
await LocalStorageService.importJsonFile()
|
final success =
|
||||||
? null
|
await LocalStorageService.importJsonFile();
|
||||||
: showCupertinoDialog(
|
if (!success && context.mounted) {
|
||||||
context: context,
|
showCupertinoDialog(
|
||||||
builder: (context) => CupertinoAlertDialog(
|
context: context,
|
||||||
title: const Text('Fehler'),
|
builder: (context) => CupertinoAlertDialog(
|
||||||
content: const Text(
|
title: const Text('Fehler'),
|
||||||
'Datei konnte nicht importiert werden.'),
|
content: const Text(
|
||||||
actions: [
|
'Datei konnte nicht importiert werden.'),
|
||||||
CupertinoDialogAction(
|
actions: [
|
||||||
child: const Text('OK'),
|
CupertinoDialogAction(
|
||||||
onPressed: () =>
|
child: const Text('OK'),
|
||||||
Navigator.pop(context),
|
onPressed: () => Navigator.pop(context),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
))
|
));
|
||||||
}),
|
}
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
|
|||||||
Reference in New Issue
Block a user