ReactterBuilder<T extends ReactterContext?> class

A wrapper 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.stateHook.value}");
  },
)

NOTE: ReactterBuilder is read-only by default, this means it only renders once.

NOTE: ReactterBuilder is a "scoped". So it contains a ReactterScope which the builder callback will be rebuild, when the ReactterContext changes. For this to happen, the ReactterContext should put it on listens for BuildContext's watchers.

If you want to listen for all ReactterContext's changes to re-render builder callback, use listenAllHooks property as true.

If you want to listen for some ReactterContext's ReactterHook to re-render builder callback, use listenHooks.

If you don't want to rebuild a part of builder callback, use the child property, it's more efficient to build that subtree once instead of rebuilding it on every ReactterContext changes.

ReactterBuilder<AppContext>(
  listenAllHooks: true,
  child: Text("This widget build only once"),
  builder: (appContext, context, child) {
    return Column(
      children: [
        Text("state: ${appContext.stateHook.value}"),
        child,
      ],
    );
  },
)
Inheritance

Constructors

ReactterBuilder({Key? key, String? id, 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
listenAllHooks bool
Watchs all hooks to re-render
final
listenHooks ListenHooks<T>?
Watchs specific hooks to re-render
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}) 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