Hook<Result, Data> class
abstract
Allows a Widget to create and access its own mutable data without a State.
A State and a Hook are similar, in that they house a widget's logic and internal state. But instead of returning a Widget subtree, Hook.build can return any value.
A widget can access a Hook if its BuildContext is an Element with the HookElement mixin.
- Mixed-in types
Constructors
- Hook()
Properties
- context → BuildContext
-
Equivalent of State.context for Hook
no setter
- data → Data
-
Equivalent of State.widget for a Hook.
no setter
- debugResult → Object?
-
The value shown in the devtool.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
activate(
) → void - Equivalent of State.deactivate for Hook.
-
build(
) → Result - Called everytime the Hook is requested.
-
deactivate(
) → void - Equivalent of State.deactivate for Hook.
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
override
-
didChangeDependencies(
) → void - Equivalent of State.didChangeDependencies for Hook.
-
didUpdate(
Data oldHook) → void - Equivalent of State.didUpdateWidget for Hook.
-
dispose(
) → void - Equivalent of State.dispose for Hook.
-
initHook(
) → void - Equivalent of State.initState for Hook.
-
markMayNeedRebuild(
) → void - Mark the associated HookWidget as potentially needing to rebuild.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reassemble(
) → void - In addition to this method being invoked, it is guaranteed that the build method will be invoked when a reassemble is signaled. Most widgets therefore do not need to do anything in the reassemble method.
-
setState(
[VoidCallback? fn]) → void - Equivalent of State.setState for Hook.
-
shouldRebuild(
) → bool - Called before a build triggered by markMayNeedRebuild.
-
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