OnCRUDBuilder class Null safety

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.

  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.


OnCRUDBuilder({Key? key, required InjectedCRUD listenTo, Widget onWaiting()?, Widget onError(dynamic, void ())?, required Widget onResult(dynamic), void dispose()?, @Deprecated('') On<void>? onSetState, String? debugPrintWhenRebuild})


debugPrintWhenRebuild String?
Debug print informative message when this widget is rebuilt
dispose → (void Function?()?)
Side effects to call when this widget is disposed.
hashCode int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
key Key?
Controls how one widget replaces another widget in the tree. [...]
final, inherited
listenTo InjectedCRUD
onError → (Widget Function?(dynamic, void ())?)
Widget to display if a CRUD operation fails
onResult Widget Function(dynamic)
Widget to display if a CRUD operation ends successfully. It exposes the result of the CRUD operation
onSetState On<void>?
Side effects to call InjectedAuth emits notification.
onWaiting → (Widget Function?()?)
Widget to display while waiting for any CRUD operation
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


build(BuildContext context) Widget
Describes the part of the user interface represented by this widget. [...]
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree. [...]
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children. [...]
@protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. [...]
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object. [...]
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants. [...]
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object. [...]
toStringShort() String
A short, textual description of this widget.


operator ==(Object other) bool
The equality operator. [...]
@nonVirtual, inherited