[pve-devel] [PATCH pve_flutter_frontend v5 2/3] refactor: noVNC: seperate duplicate onTap implementation

Shan Shaji s.shaji at proxmox.com
Mon Aug 18 12:01:33 CEST 2025


The noVNC console opening implementation was the same for all guests.
However, the code in this section was duplicated. To fix this, extract
the duplicate logic into a single function and use that function as
the `onTap` callback.

Signed-off-by: Shan Shaji <s.shaji at proxmox.com>
---
 lib/widgets/pve_console_menu_widget.dart | 43 ++++++++----------------
 1 file changed, 14 insertions(+), 29 deletions(-)

diff --git a/lib/widgets/pve_console_menu_widget.dart b/lib/widgets/pve_console_menu_widget.dart
index 6de2c0b..66a852c 100644
--- a/lib/widgets/pve_console_menu_widget.dart
+++ b/lib/widgets/pve_console_menu_widget.dart
@@ -105,35 +105,7 @@ class PveConsoleMenu extends StatelessWidget {
                   style: TextStyle(fontWeight: FontWeight.bold),
                 ),
                 subtitle: const Text("Open console view"),
-                onTap: () async {
-                    if (['qemu', 'lxc'].contains(type)) {
-                      SystemChrome.setEnabledSystemUIMode(
-                          SystemUiMode.immersive);
-                      Navigator.of(context)
-                          .push(_createHTMLConsoleRoute())
-                          .then((completion) {
-                        SystemChrome.setEnabledSystemUIMode(
-                            SystemUiMode.edgeToEdge,
-                            overlays: [
-                              SystemUiOverlay.top,
-                              SystemUiOverlay.bottom
-                            ]);
-                      });
-                    } else if (type == 'node') {
-                      SystemChrome.setEnabledSystemUIMode(
-                          SystemUiMode.immersive);
-                      Navigator.of(context)
-                          .push(_createHTMLConsoleRoute())
-                          .then((completion) {
-                        SystemChrome.setEnabledSystemUIMode(
-                            SystemUiMode.edgeToEdge,
-                            overlays: [
-                              SystemUiOverlay.top,
-                              SystemUiOverlay.bottom
-                            ]);
-                      });
-                    }
-                },
+                onTap: () => _openNoVncConsole(context, type),
               ),
           ],
         ),
@@ -141,6 +113,19 @@ class PveConsoleMenu extends StatelessWidget {
     );
   }
 
+  Future<void> _openNoVncConsole(BuildContext context, String type) async {
+    if(!['lxc', 'node', 'qemu'].contains(type)) return;
+    SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
+    await Navigator.push(context, _createHTMLConsoleRoute());
+    SystemChrome.setEnabledSystemUIMode(
+      SystemUiMode.edgeToEdge,
+      overlays: [
+        SystemUiOverlay.top,
+        SystemUiOverlay.bottom,
+      ],
+    );
+  }
+
   void showTextDialog(BuildContext context, String title, String content) {
     showDialog(
       context: context,
-- 
2.50.1





More information about the pve-devel mailing list