OnCRUDBuilder class

To listen to an InjectedCRUD state just use ReactiveStatelessWidget, OnReactive, or OnBuilder widgets.

Nevertheless, as the CREATE, UPDATE, DELETE functions can be performed optimistically, the user will not notice anything. Looks like he's dealing with a simple sync list of items.

If we want to show the user that something is happening in the background, we can use the OnCRUDBuilder widget.

OnCRUDBuilder<T>(
  listenTo: products,
  onWaiting: ()=> Text('onWaiting'),
  onError: (err, refreshErr)=> Text('onError'),
  onResult: (result)=> Text('onResult'),
)
  • onWaiting: while the database is querying.
  • onError: if the query ends with an error. IT exposes a refresher to reinvoke the async call that caused the error.
  • onResult; if the request ends successfully. It exposes the result fo the query (ex: number of rows updated).

OnCRUDBuilder vs OnBuilder.all or OnBuilder.orElse:

  • Both used to listen to injected state.
  • In pessimistic mode they are equivalent.
  • In optimistic mode, the difference is in the onWaiting hook.
    • In OnBuilder.all the onWaiting in never called.
    • In OnCRUDBuilder the onWaiting is called while waiting for the backend service result.
  • OnBuilder.all has onData callback.
  • OnCRUDBuilder has onResult callback that exposes the return result for the backend service.
Inheritance

Constructors

OnCRUDBuilder({Key? key, required InjectedCRUD listenTo, Widget onWaiting()?, Widget onError(dynamic, void ())?, required Widget onResult(dynamic), void dispose()?, String? debugPrintWhenRebuild})
To listen to an InjectedCRUD state just use ReactiveStatelessWidget, OnReactive, or OnBuilder widgets.

Properties

cleaners List<VoidCallback>
finalinherited
debugPrintWhenRebuild String?
finalinherited
didChangeDependencies → void Function(BuildContext context, ReactiveModel? model)?
finalinherited
didUpdateWidget → void Function(BuildContext context, ReactiveModel? model, MyStatefulWidget oldWidget)?
finalinherited
dispose → void Function(BuildContext context, ReactiveModel? model)?
finalinherited
hashCode int
The hash code for this object.
no setterinherited
initState → void Function(BuildContext context, ReactiveModel? model)?
finalinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
listenTo InjectedCRUD
InjectedCRUD to listen to
final
observers List<ReactiveModelImp> Function(BuildContext context)
finalinherited
onError Widget Function(dynamic, void ())?
Widget to display if a CRUD operation fails
final
onResult Widget Function(dynamic)
Widget to display if a CRUD operation ends successfully. It exposes the result of the CRUD operation
final
onSetState → void Function(BuildContext, SnapState, ReactiveModel)?
finalinherited
onWaiting Widget Function()?
Widget to display while waiting for any CRUD operation
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shouldRebuild ShouldRebuild?
Whether to rebuild the widget after state notification.
finalinherited
sideEffects SideEffects?
finalinherited

Methods

builder(BuildContext context, SnapState snap, ReactiveModel rm) Widget
inherited
createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → _MyStatefulWidgetState
Creates the mutable state for this widget at a given 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