Ian VanSchooten 2024-08-29 10:21:51 -04:00
parent 47e005bdf8
commit afd655f86d
1 changed files with 7 additions and 11 deletions

View File

@ -1,5 +1,3 @@
import 'dart:async';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:mobile_nebula/components/SimplePage.dart'; import 'package:mobile_nebula/components/SimplePage.dart';
@ -40,19 +38,17 @@ class _FormPageState extends State<FormPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
changed = widget.changed || changed; changed = widget.changed || changed;
return WillPopScope( return PopScope(
onWillPop: () { canPop: false,
if (!changed) { onPopInvoked: (bool didPop) async {
return Future.value(true); if (didPop) {
return;
} }
final NavigatorState navigator = Navigator.of(context);
var completer = Completer<bool>();
Utils.confirmDelete(context, 'Discard changes?', () { Utils.confirmDelete(context, 'Discard changes?', () {
completer.complete(true); navigator.pop();
}, deleteLabel: 'Yes', cancelLabel: 'No'); }, deleteLabel: 'Yes', cancelLabel: 'No');
return completer.future;
}, },
child: SimplePage( child: SimplePage(
leadingAction: _buildLeader(context), leadingAction: _buildLeader(context),