Page inherits from Component. When buildPage is built, a private _pageWidget is called from the parent Component’s _wrapper class. This _pageWidget inherits from StatefulWidget and is built from the parameters passed in.

The _wrapper in Component is a Function signature typedef WidgetWrapper = Widget Function(Widget child); If the wrapper is empty, it uses a default _wrapperByDefault as the wrapper. This _wrapperByDefault returns only the child. static Widget _wrapperByDefault(Widget child) => child;

The Component class defines a createState() function that returns a ComponentState inherited from the StatefulWidget. Check within the Component buildComponent method that if pureView is not returned ComponentWidget. PureView’s judgment is as follows:

bool isPureView() {
    return protectedReducer == null &&
        protectedEffect == null &&
        protectedDependencies == null;
  }
Copy the code

PureView does not hold the current Component, only ComponentWidget holds the current Component

We all know that when we use animations like this, we have to mixin a TickerProvider, which is with when State is defined. TickerProviderStateMixin is a mixin on State. It is used for the life cycle of the state given to the StatefulWidget. There is no method defined in page that can fetch the state of the _pageWidget, and no related createState method is exposed to mount it to its private _pageState. You can override the Component createState method and mix it in, because Component createState returns ComponentState. ComponentState

createState() => ComponentState

(); CreateState () => Component.creatEstate (); ComponentState

createState() => Component.creatEstate ();


But this is just a method, so how do you make a mixin, you make a mixin, and then you return it in createState, and then you just use it as state, you don’t need callSuper, It is an independent ComponentState, inherited from State, rewrite the build method and a series of methods should have, and just mixed, other methods or use the parent class ComponentState.

It is suggested to accompany the next companion article

Everyone big guy I am a vegetable dog, if the compilation is wrong, also please help correct, very grateful