Flutter: AutomaticKeepAliveClientMixin is not working with BottomNavigationBar

后端 未结 3 1254
情书的邮戳
情书的邮戳 2020-12-13 10:33

I have page called AddPatientView with BottomNavigationBar containing AddPatientInfo and AddPatientImages pages. All of these three are Stateful widgets.

By default

3条回答
  •  盖世英雄少女心
    2020-12-13 10:51

    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 example, before you return the Scaffold just call super.build:

      Widget build(BuildContext context) {
        super.build(context);
        return Scaffold(...);
      }
    

提交回复
热议问题