DeexConsumer<S extends DeexStore> class
A widget that listens to a DeexStore
and rebuilds when the state changes.
It combines both a builder
and a listener
callback.
Example:
class CounterStore extends DeexStore {
int _count = 0;
int get count => _count;
void increment() {
_count++;
update();
}
}
class CounterPage extends StatelessWidget {
final CounterStore store = CounterStore();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Counter')),
body: DeexConsumer<CounterStore>(
store: store,
listener: (context, store) {
// You can show a snack bar or perform other side effects here
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Counter updated: ${store.count}')),
);
},
builder: (context, store) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('You have pushed the button this many times:'),
Text('${store.count}', style: Theme.of(context).textTheme.headline4),
],
),
);
},
),
floatingActionButton: FloatingActionButton(
onPressed: store.increment,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- DeexConsumer
Constructors
-
DeexConsumer.new({Key? key, required S store, required DeexBuilder<
S> builder, DeexListener<S> ? listener, List<Object> ? listenIds}) -
const
Properties
-
builder
→ DeexBuilder<
S> -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
listener
→ DeexListener<
S> ? -
final
-
listenIds
→ List<
Object> ? -
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- store → S
-
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → DeexConsumerState< S> -
Creates the mutable state for this widget at a given location in the tree.
override
-
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