StatefulElement constructor
StatefulElement(
- StatefulComponent component
Creates an element that uses the given component as its configuration.
Implementation
StatefulElement(StatefulComponent component)
: _state = component.createState(),
super(component) {
assert(() {
if (!state._debugTypesAreRight(component)) {
throw 'StatefulComponent.createState must return a subtype of State<${component.runtimeType}>\n\n'
'The createState function for ${component.runtimeType} returned a state '
'of type ${state.runtimeType}, which is not a subtype of '
'State<${component.runtimeType}>, violating the contract for createState.';
}
return true;
}());
assert(state._element == null);
state._element = this;
assert(
state._component == null,
'The createState function for $component returned an old or invalid state '
'instance: ${state._component}, which is not null, violating the contract '
'for createState.',
);
state._component = component;
assert(state._debugLifecycleState == _StateLifecycle.created);
}