flutter 解决tab 每次都刷新的问题

2022-11-17  本文已影响0人  微笑城ios

使用 IndexdStack 包一层

body: IndexedStack(
        index: _curtentIndex,
        children: pages,
      ),

然后添加

  1. AutomaticKeepAliveClientMixin
  2. bool get wantKeepAlive => true;
class HomePageState extends State<HomePage> with AutomaticKeepAliveClientMixin {
  @override
  // TODO: implement wantKeepAlive
  bool get wantKeepAlive => true;

好了 大概酱紫

上一篇 下一篇

猜你喜欢

热点阅读