TaskConstraints class final
Constraints that must be satisfied before a background task executes.
- Annotations
Constructors
- TaskConstraints({NetworkConstraint? network, bool batteryNotLow = false, bool requiresCharging = false, bool deviceIdle = false})
-
Creates a TaskConstraints instance.
const
-
TaskConstraints.fromMap(Map<
String, dynamic> map) -
Deserializes from a map (e.g., from platform event).
factory
Properties
- batteryNotLow → bool
-
Task will only run if device battery is not low.
Android:
setRequiresBatteryNotLow(true). iOS: checked in Dart before execution.final - deviceIdle → bool
-
Task will only run when device is idle.
Android:
setRequiresDeviceIdle(true). iOS: not supported — logged as warning.final - hashCode → int
-
The hash code for this object.
no setteroverride
- network → NetworkConstraint?
-
Network requirement.
nullmeans no network constraint.final - requiresCharging → bool
-
Task will only run if device is charging.
Android:
setRequiresCharging(true). iOS:requiresExternalPower = true.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toMap(
) → Map< String, dynamic> - Serializes to a map for passing to the platform.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override