CommandAsync<TParam, TResult> class
- Inheritance
-
- Available Extensions
Constructors
-
CommandAsync({Future<TResult> func(TParam)?, Future<TResult> funcNoParam()?, required TResult initialValue, required ValueListenable<bool>? restriction, required ExecuteInsteadHandler<TParam>? ifRestrictedExecuteInstead, required bool includeLastResultInCommandResults, required bool noReturnValue, required ErrorFilter? errorFilter, required bool notifyOnlyWhenValueChanges, required String? debugName, required bool noParamValue})
-
Properties
-
asyncNotification
→ bool
-
If true, the listeners will be notified asynchronously, which can be helpful
if you encounter problems that you trigger rebuilds during the build phase.
finalinherited
-
canExecute
→ ValueListenable<bool>
-
ValueListenable<bool>
that changes its value on any change of the current
executability state of the command. Meaning if the command can be executed or not.
This will issue false
while the command executes, but also if the command
receives a true
from the restriction
ValueListenable
that you can pass when
creating the Command.
its value is !restriction.value && !isExecuting.value
no setterinherited
-
debugName
→ String?
-
no setterinherited
-
errors
→ ValueListenable<CommandError?>
-
ValueListenable<CommandError>
that reflects the Error State of the command
if the wrapped function throws an error, its value is set to the error is
wrapped in an CommandError
no setterinherited
-
hashCode
→ int
-
The hash code for this object.
no setterinherited
-
hasListeners
→ bool
-
Whether any listeners are currently registered.
no setterinherited
-
isExecuting
→ ValueListenable<bool>
-
ValueListenable
that changes its value on any change of the execution
state change of the command
no setterinherited
-
listenerCount
↔ int
-
getter/setter pairinherited
-
mode
→ CustomNotifierMode
-
finalinherited
-
results
→ ValueListenable<CommandResult<TParam?, TResult>>
-
emits
CommandResult<TResult>
the combined state of the command, which is
often easier in combination with Flutter's ValueListenableBuilder
because you have all state information at one place.
no setterinherited
-
runtimeType
→ Type
-
A representation of the runtime type of the object.
no setterinherited
-
thrownExceptions
→ ValueListenable<CommandError?>
-
ValueListenable<CommandError>
that reflects the Error State of the command
if the wrapped function throws an error, its value is set to the error is
wrapped in an CommandError
no setterinherited
-
value
↔ TResult
-
The current value of the object. When the value changes, the callbacks
registered with addListener will be invoked.
getter/setter pairinherited
Methods
-
addListener(void listener())
→ void
-
Register a closure to be called when the object changes.
inherited
-
call([TParam? param])
→ void
-
This makes Command a callable class, so instead of
myCommand.execute()
you can write myCommand()
inherited
-
clearErrors()
→ void
-
clears the error state of the command. This will trigger any listeners
especially useful if you use
watch_it
to watch the errors property.
However the prefered way to handle thd errors property is either user
registerHandler
or listen
in initState
of a StatefulWidget
inherited
-
dispose()
→ void
-
If you don't need a command any longer it is a good practise to
dispose it to make sure all registered notification handlers are remove to
prevent memory leaks
inherited
-
execute([TParam? param])
→ void
-
Calls the wrapped handler function with an optional input parameter
inherited
-
executeWithFuture([TParam? param])
→ Future<TResult>
-
Executes an async Command and returns a Future that completes as soon as
the Command completes. This is especially useful if you use a
RefreshIndicator
inherited
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners()
→ void
-
Call all the registered listeners.
inherited
-
removeListener(void listener())
→ void
-
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
toString()
→ String
-
A string representation of this object.
inherited
-
toWidget({required Widget onResult(TResult lastResult, TParam? param), Widget whileExecuting(TResult lastResult, TParam? param)?, Widget onError(Object? error, TParam? param)?})
→ Widget
-
Returns a the result of one of three builders depending on the current state
of the Command. This function won't trigger a rebuild if the command changes states
so it should be used together with get_it_mixin, provider, flutter_hooks and the like.
inherited