LifecycleHooksStateMixin<T extends StatefulWidget> mixin
Mixin providing lifecycle hooks for State classes.
Extends LifecycleCallbacks with Flutter lifecycle method overrides that automatically run registered callbacks at the correct times.
class _MyState extends State<MyWidget>
with LifecycleCallbacks, LifecycleHooksStateMixin {
@override
void initState() {
super.initState();
onMounted(() => print('Mounted!'));
onDispose(() => print('Disposing...'));
}
}
- Superclass constraints
- Mixin applications
Properties
- context → BuildContext
-
The location in the tree where this widget builds.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- mounted → bool
-
Whether this State object is currently in a tree.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- widget → T
-
The current configuration.
no setterinherited
Methods
-
activate(
) → void -
Called when this object is reinserted into the tree after having been
removed via deactivate.
override
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
inherited
-
deactivate(
) → void -
Called when this object is removed from the tree.
override
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
didChangeDependencies(
) → void -
Called when a dependency of this State object changes.
override
-
didUpdateWidget(
covariant T oldWidget) → void -
Called whenever the widget configuration changes.
override
-
dispose(
) → void -
Called when this object is removed from the tree permanently.
override
-
initState(
) → void -
Called when this object is inserted into the tree.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onActivate(
LifecycleCallback callback, {LifecycleTiming timing = LifecycleTiming.after}) → void -
Register a callback for activate lifecycle.
inherited
-
onDeactivate(
LifecycleCallback callback, {LifecycleTiming timing = LifecycleTiming.after}) → void -
Register a callback for deactivate lifecycle.
inherited
-
onDidChangeDependencies(
LifecycleCallback callback, {LifecycleTiming timing = LifecycleTiming.after}) → void -
Register a callback for didChangeDependencies lifecycle.
inherited
-
onDidUpdateWidget<
T> (DidUpdateWidgetCallback< T> callback, {LifecycleTiming timing = LifecycleTiming.after}) → void -
Register a callback for didUpdateWidget lifecycle.
inherited
-
onDispose(
LifecycleCallback callback, {LifecycleTiming timing = LifecycleTiming.before}) → void -
Register a callback for dispose lifecycle.
inherited
-
onErrorCaptured(
ErrorCallback callback) → void -
Register an error handler.
inherited
-
onInitState(
LifecycleCallback callback, {LifecycleTiming timing = LifecycleTiming.after}) → void -
Register a callback for initState lifecycle.
inherited
-
onMounted(
LifecycleCallback callback) → void -
Register a callback after the first frame renders.
inherited
-
onReassemble(
LifecycleCallback callback, {LifecycleTiming timing = LifecycleTiming.after}) → void -
Register a callback for reassemble lifecycle (hot reload).
inherited
-
reassemble(
) → void -
Called whenever the application is reassembled during debugging, for
example during hot reload.
override
-
runActivateCallbacks(
LifecycleTiming timing) → void -
Run activate callbacks.
inherited
-
runDeactivateCallbacks(
LifecycleTiming timing) → void -
Run deactivate callbacks.
inherited
-
runDidChangeDependenciesCallbacks(
LifecycleTiming timing) → void -
Run didChangeDependencies callbacks.
inherited
-
runDidUpdateWidgetCallbacks<
T> (LifecycleTiming timing, T oldWidget, T widget) → void -
Run didUpdateWidget callbacks.
inherited
-
runDisposeCallbacks(
LifecycleTiming timing) → void -
Run dispose callbacks.
inherited
-
runErrorCapturedCallbacks(
Object error, StackTrace stack) → bool -
Run error callbacks.
inherited
-
runInitStateCallbacks(
LifecycleTiming timing) → void -
Run initState callbacks.
inherited
-
runMountedCallbacks(
) → void -
Run mounted callbacks.
inherited
-
runReassembleCallbacks(
LifecycleTiming timing) → void -
Run reassemble callbacks.
inherited
-
scheduleMountedCallbackIfNeeded(
) → void - Schedule mounted callback after first build. Call this at end of build() method.
-
setState(
VoidCallback fn) → void -
Notify the framework that the internal state of this object has changed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringShort(
) → String -
A brief description of this object, usually just the runtimeType and the
hashCode.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited