簡體   English   中英

Flutter:go_router 6.0.1 KEYCODE_BACK 在 ShellRoute 中拋出 null 安全錯誤

[英]Flutter: go_router 6.0.1 KEYCODE_BACK throw null safety error in ShellRoute

在我的應用程序中,我有 ShellRoute,我將其用於 BottomNavigation。 如果我在所選選項卡上使用系統后退按鈕或手勢,我會收到 null 安全錯誤,我不知道如何擺脫它。

在此處輸入圖像描述 在此處輸入圖像描述

錯誤出現在class GoRouterDelegate中的delegate.dart。

在此處輸入圖像描述

WillPopScope 對我不起作用,因為錯誤是較早出現的。

我的問題的解決方案是重做底部導航,如示例所示:

https://github.com/flutter/packages/blob/main/packages/go_router/example/lib/shell_route.dart

   ShellRoute(
    navigatorKey: _shellNavigatorKey,
    builder: (BuildContext context, GoRouterState state, Widget child) {
      return ScaffoldWithNavBar(child: child);
    },
   ....

需要在ShellRoute內部傳一個child,在里面解決不行否則傳不上context。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM