美文网首页
flutter TabBarView不保持child的state

flutter TabBarView不保持child的state

作者: liboxiang | 来源:发表于2019-10-15 09:16 被阅读0次

    TabBarView中的children要实现AutomaticKeepAliveClientMixin(用with),且重写wantKeepAlive方法

    @protected
      bool get wantKeepAlive => true;
    

    在build方法中还需要调用super.build(context);

    相关文章

      网友评论

          本文标题:flutter TabBarView不保持child的state

          本文链接:https://www.haomeiwen.com/subject/ukvqmctx.html