]> git.proxmox.com Git - flutter/pve_flutter_frontend.git/commitdiff
main layout: replace depreacated WillPopScope with PopScope
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 11 Apr 2024 09:43:13 +0000 (11:43 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 11 Apr 2024 10:37:44 +0000 (12:37 +0200)
We use this to handle back navigation for our bottom navigation
drawer manually, something which we might want to revisit in the
future in general, but for now just replace this with a
non-depreacted variant.

There set canPop to false to disable the auto-pop of the framework
and handle popping then manually.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
lib/pages/main_layout_slim.dart

index 3fef805fec4597477d4849cd0c150f694f7f360e..ae6dacbfe3ef2ba0b78b1c7a1616621651365317 100644 (file)
@@ -67,13 +67,14 @@ class _MainLayoutSlimState extends State<MainLayoutSlim> {
           dispose: (context, bloc) => bloc.dispose(),
         )
       ],
-      child: WillPopScope(
-        onWillPop: () async {
-          if (pageSelector.value != 0) {
-            pageSelector.add(0);
-            return false;
+      child: PopScope(
+        canPop: false,
+        onPopInvoked: (didPop) async {
+          if (didPop || pageSelector.value != 0) {
+            if (pageSelector.value != 0) pageSelector.add(0);
+            return;
           }
-          return true;
+          if (mounted) Navigator.of(context).pop();
         },
         child: StreamBuilder<int>(
           stream: pageSelector.stream,