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