flutter's AutomaticKeepAliveClientMixin doesn't keep the page state after navigator.push

前端 未结 1 727
抹茶落季
抹茶落季 2021-02-07 03:48

was testing AutomaticKeepAliveClientMixin and run into an issue, page loses state after navigator.push anyone knows this issue? any workarounds? be glad for any info, cheers

相关标签:
1条回答
  • 2021-02-07 04:25

    From the documentation on AutomaticKeepAliveClientMixin:

    /// A mixin with convenience methods for clients of [AutomaticKeepAlive]. Used with [State] subclasses.

    /// Subclasses must implement [wantKeepAlive], and their [build] methods must call super.build (the return value will always return null, and should be ignored).

    So in your code, before you return the ListView just call super.build:

      Widget build(BuildContext context) {
        super.build(context);
        return ListView(..
      }
    
    0 讨论(0)
提交回复
热议问题