StatefulViewElement<VM extends ViewModel> constructor
StatefulViewElement<VM extends ViewModel> (
- StatefulView<
VM> view
Creates an element that uses the given widget as its configuration.
Implementation
StatefulViewElement(StatefulView<VM> view)
: _state = view.createState(),
super(view) {
assert(() {
if (!state._debugTypesAreRight(view)) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary(
'StatefulWidget.createState must return a subtype of State<${view.runtimeType}>'),
ErrorDescription(
'The createState function for ${view.runtimeType} returned a state '
'of type ${state.runtimeType}, which is not a subtype of '
'State<${view.runtimeType}>, violating the contract for createState.',
),
]);
}
return true;
}());
assert(state._element == null);
state._element = this;
assert(
state._widget == null,
'The createState function for $view returned an old or invalid state '
'instance: ${state._widget}, which is not null, violating the contract '
'for createState.',
);
state._widget = view;
assert(state._debugLifecycleState == _ViewStateLifecycle.created);
}