ReactterBuilder<T extends ReactterContext?> class
A StatelessWidget that gets the ReactterContext's instance of T
from the closest ancestor of ReactterProvider and exposes it through
the first parameter of builder callback.
ReactterBuilder<AppContext>(
builder: (appContext, context, child) {
return Text("state: ${appContext.stateA.value}");
},
)
NOTE: ReactterBuilder is read-only by default, this means it only renders once.
Use id property to find a instances of T
with an identify.
Use listenStates property to listen states, and when it changed, ReactterBuilder's builder callback re-built.
Use listenAll property as true to listen all states, and when it changed, ReactterBuilder's builder callback re-built.
CONSIDER Use child property to pass a Widget that you want to build it once. The ReactterBuilder pass it through the builder callback, so you can incorporate it into your build:
ReactterBuilder<AppContext>(
listenAll: true,
child: Text("This widget build only once"),
builder: (appContext, context, child) {
return Column(
children: [
Text("state: ${appContext.stateHook.value}"),
child,
],
);
},
)
See also:
- ReactterProvider, a StatelessWidget that provides a
ReactterContext's instance of
T
to widget tree that can be access through the BuildContext. - ReactterContext, a base-class that allows to manages the ReactterHooks.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- ReactterBuilder
Constructors
-
ReactterBuilder.new({Key? key, String? id, ListenStates<
T> ? listenStates, bool listenAll = false, ListenHooks<T> ? listenHooks, bool listenAllHooks = false, Widget? child, InstanceBuilder<T> ? builder}) -
const
Properties
-
builder
→ InstanceBuilder<
T> ? -
Exposes the
BuilderContext
along with the child.final - child → Widget?
-
Provides a widget , which render only once.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String?
-
Id of
T
.final - key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- listenAll → bool
-
Watchs all states to re-build
final
- listenAllHooks → bool
-
Watchs all hooks to re-build
final
-
listenHooks
→ ListenHooks<
T> ? -
Watchs specific hooks to re-build
final
-
listenStates
→ ListenStates<
T> ? -
Watchs specific states to re-build
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
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
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited