How to Manage state between tabs in Flutter App

旧时模样 提交于 2019-12-06 10:29:06

I think what you may be after is AutomaticKeepAliveClientMixin. I always add that to my screen widgets within TabBarView. This way when a user enters data into fields in one tab and navigates to other tabs and back the data is still there as you would expect. Then when the user performs an action like "save" I deal with state management (BLoC etc).

You may want to use architecture for managing and sharing states. There are many approaches to manage state:

  1. InheritedWidget to pass app state down the widget hierarchy
  2. Scoped model library to hold app state and notify Widgets of Updates
  3. Redux library to manage app state and update Widgets
  4. Business Logic Components (BLoC)

Check out this article. Check this GitHub repository with different architecture examples

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!