How to update Flutter Cards in StreamBuilder without reseting state?

怎甘沉沦 提交于 2019-12-04 12:18:22

There is a widget that can do that : IndexedStack, it preserves the state of all the children in the stack, while allowing you to switch between them:

IndexedStack(
index: _widgetIndex,
children: [
 WidgetOne(),
 WidgetTwo()
]
)

You can use setState() any where in the code to change the widget that should be displayed by modifiying the value of _widgetIndex

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