Flutter - ListView inside on a TabBarView loses its scroll position

前端 未结 7 1527
误落风尘
误落风尘 2021-01-30 11:07

I have a very simple Flutter app with a TabBarView with two views (Tab 1 and Tab 2), one of them (Tab 1) has

7条回答
  •  走了就别回头了
    2021-01-30 11:17

    Is there a way to execute Widget build(BuildContext context) method only once...

    Imho, idea of flutter is to be ready for rebuilding always. It should be cheap. If you have some expensive actions, you can use State to "cache" results. E.g. you can do network request in initState and via setState rebuild when receive response. For tabs, you can prepare and save data in parent widget. You can find more info in flutter tutorial about managing state

提交回复
热议问题