NWAction class
What happens when the user taps an NWButton or the widget itself.
increment, decrement, toggle, set and cycle are native actions: the generated widget code changes the stored value and redraws on its own, without starting Dart. Use callback when the reaction needs your Dart code (network, database, ...).
| Action | Android | iOS 17+ | iOS 14–16 |
|---|---|---|---|
| openApp | ✅ | ✅ | ✅ |
| native | ✅ | ✅ (App Intent) | opens the app, which applies it |
| callback | ✅ | ✅ (App Intent) | opens the app, which runs it |
Constructors
- NWAction.callback(String key, {String? payload})
-
Runs your
@WidgetCallbackfunctions in a background isolate.payloadis passed along asWidgetEvent.payload.const -
NWAction.cycle(String key, List<
String> values) -
Moves the field to the next entry of
values, wrapping around.const - NWAction.decrement(String key, {int by = 1, int? min, int? max})
-
const
- NWAction.increment(String key, {int by = 1, int? min, int? max})
-
const
- NWAction.openApp([String? url])
-
Opens the app.
urlarrives inFlutterNativeWidget.launches; defaults to the widget's name.const - NWAction.set(String key, String value)
-
const
- NWAction.toggle(String key)
-
const
Properties
- by → int
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → String
-
The field the action changes, or the callback name.
final
- kind → NWActionKind
-
final
- max → int?
-
final
- min → int?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → String?
-
For set: the new value. For openApp: the URL or route.
final
-
values
→ List<
String> ? -
For cycle: the values to step through.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited