RemoterMutation<T, S> class

Used to simplify handling asynchronous calls T represents type of the value execute function returns S represents type of the value passed to mutate function which will be passed to execute function as parameter

  RemoterMutation<T, S>(
   execute: (param) async {
     await Future.delayed(const Duration(seconds: 1));
   },
   builder: (context, snapshot, utils) {
     return Scaffold(
       body: Center(
         child: Column(
           mainAxisAlignment: MainAxisAlignment.center,
           children: <Widget>[
             if (snapshot.status == RemoterStatus.fetching)
               const Text(
                 'loading...',
               ),
             if (snapshot.status == RemoterStatus.error)
               const Text(
                 'error occured',
               ),
             Text(
               snapshot.data ?? "idle",
               style: Theme.of(context).textTheme.headline4,
             ),
           ],
         ),
       ),
       floatingActionButton: FloatingActionButton(
         onPressed: snapshot.status == RemoterStatus.fetching
             ? null
             : () {
                 utils.mutate(null);
               },
         child: const Icon(Icons.add),
       ),
     );
  });
Inheritance

Constructors

RemoterMutation({Key? key, dynamic listener(RemoterMutationData<T> oldState, RemoterMutationData<T> newState)?, int? maxDelay, int? maxRetries, required FutureOr<T> execute(S param), required Widget builder(BuildContext context, RemoterMutationData<T> snapshot, RemoterMutationUtils<T, S> utils)})
Used to simplify handling asynchronous calls T represents type of the value execute function returns S represents type of the value passed to mutate function which will be passed to execute function as parameter
const

Properties

builder Widget Function(BuildContext context, RemoterMutationData<T> snapshot, RemoterMutationUtils<T, S> utils)
Builder method that is called when data updates
final
execute FutureOr<T> Function(S param)
Function to fetch data
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 → (dynamic Function(RemoterMutationData<T> oldState, RemoterMutationData<T> newState)?)
Listener function that receives updates of data
final
maxDelay int?
Maximum delay between retries of execute function in ms If omitted falls back to maxDelay of top level RemoterClient.options
final
maxRetries int?
Maximum number of retries running execute function If omitted falls back to maxRetries of top level RemoterClient.options
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<RemoterMutation<T, 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}) 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