Flutter tabBar切換頁面防止重置

TabBar 配合TabBarView切換頁面,然後每個頁面是一個列表加載數據,但是切換頁面後listview的數據會被重置,

重新被加載了,解決辦法使用 with AutomaticKeepAliveClientMixin 實現 @protected bool get wantKeepAlive=>true

class _OpenLogListComponentState extends State<OpenLogListComponent> with AutomaticKeepAliveClientMixin{
 
  @protected
  bool get wantKeepAlive=>true;
 
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章