[英]How to hide bottom tab navigator (persistent_bottom_nav_bar) when the screen is not the main screens-Flutter
[英]Navigator pop when using persistent_bottom_nav_bar - Flutter
我目前正在使用persistent_bottom_nav_bar: ^4.0.2
和rflutter_alert
但問題是當我調用Navigator.of(context).pop();
我總是收到這個錯誤:
FlutterError (This widget has been unmounted, so the State no longer has a context (and should be considered defunct).
Consider canceling any active work during "dispose" or using the "mounted" getter to determine if the State is still active.)
當我使用persistent_bottom_nav_bar
時會發生這種情況,我嘗試使用bottomNavigationBar
這是Scaffold
小部件的屬性,這真的很好,而且Navigator.of(context).pop();
沒有問題 . 使用persistent_bottom_nav_bar
時有沒有辦法做 Navigator pop
這對我有用。
Alert(
context: context,
type: AlertType.error,
title: "RFLUTTER ALERT",
desc: "Flutter is more awesome with RFlutter Alert.",
buttons: [
DialogButton(
child: Text(
"COOL",
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () => Navigator.of(context, rootNavigator: true).pop(),
width: 120,
)
],
).show();
閱讀此討論后,我找到了解決方案: https://github.com/RatelHub/rflutter_alert/issues/20#issuecomment-535330620 。 因此,不要使用Navigator.of(context).pop();
我將其更改為Navigator.of(context, rootNavigator: true).pop()
嘗試使用:
Navigator.pop(context);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.