简体   繁体   English

如何在底部导航栏中重新加载特定选项卡 flutter?

[英]How to reload a particular tab in bottom navigation bar flutter?

I have a bottom navigation bar with 5 tabs, In each tab I have a button that navigates to another separate screen using Navigation.pushNamed() (page 2);我有一个带有 5 个选项卡的底部导航栏,在每个选项卡中我都有一个使用Navigation.pushNamed()导航到另一个单独屏幕的按钮(第 2 页); and from (page 2) I pop the screen, now the tab from where I navigated from need to be reloaded.并从(第 2 页)弹出屏幕,现在需要重新加载我从中导航的选项卡。 because i store some data (page 2) and stored in sqflite i need to display the data in one of the tabs.因为我存储了一些数据(第 2 页)并存储在 sqflite 中,所以我需要在其中一个选项卡中显示数据。 Is it possible to reload a particular tab of a bottom navigation bar?是否可以重新加载底部导航栏的特定选项卡? I tried using Navigator.pop(context,true) that also didnt work.我尝试使用也不起作用的Navigator.pop(context,true) Can some one help me with this, thanks in advance.有人可以帮我解决这个问题,在此先感谢。

this is done by the provider.这是由提供者完成的。 I'm new to flutter as well but this guy explained it very well!我也是 flutter 的新手,但这家伙解释得很好!

Flutter by default does not save state (and disposes the widgets). Flutter 默认不保存 state (并处理小部件)。 If you want to save the state of a tab, you can use a PageStorageBucket.如果要保存选项卡的 state,可以使用 PageStorageBucket。 It is really well described in this tutorial:本教程中对此进行了很好的描述:

https://medium.com/@lucassaltoncardinali/keeping-state-with-the-bottom-navigation-bar-in-flutter-69e4168878e1 https://medium.com/@lucassaltoncardinali/keeping-state-with-the-bottom-navigation-bar-in-flutter-69e4168878e1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM