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.
- In
OnBuilder.all
has onData callback.OnCRUDBuilder
has onResult callback that exposes the return result for the backend service.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- OnCRUDBuilder
Constructors
-
OnCRUDBuilder({Key? key, required InjectedCRUD listenTo, Widget onWaiting()?, Widget onError(dynamic, void ())?, required Widget onResult(dynamic), void dispose()?, @Deprecated('') On<
void> ? onSetState, String? debugPrintWhenRebuild}) -
const
Properties
- debugPrintWhenRebuild → String?
-
Debug print informative message when this widget is rebuilt
final
- dispose → (void Function()?)
-
Side effects to call when this widget is disposed.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- listenTo → InjectedCRUD
-
final
- 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
→ On<
void> ? -
Side effects to call InjectedAuth emits notification.
final
- 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
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