BackgroundFetchConfig class
Background Fetch task Configuration
BackgroundFetch.configure(BackgroundFetchConfig(
minimumFetchInterval: 15,
stopOnTerminate: false,
startOnBoot: true,
enableHeadless: true
), (String taskId) async { // <-- Event callback
// This callback is typically fired every 15 minutes while in the background.
print('[BackgroundFetch] Event received.');
// IMPORTANT: You must signal completion of your fetch task or the OS could
// punish your app for spending much time in the background.
BackgroundFetch.finish(taskId);
}, (String taskId) async { // <-- Timeout callback
// This task has exceeded its allowed running-time. You must stop what you're doing and immediately .finish(taskId)
BackgroundFetch.finish(taskId);
});
Constructors
- BackgroundFetchConfig({required int minimumFetchInterval, bool? stopOnTerminate, bool? startOnBoot, bool? enableHeadless, bool? forceAlarmManager, NetworkType? requiredNetworkType, bool? requiresBatteryNotLow, bool? requiresStorageNotLow, bool? requiresCharging, bool? requiresDeviceIdle})
-
Creates an instance of
BackgroundFetchConfig
to provide toconfigure
.
Properties
- enableHeadless ↔ bool?
-
Android only: Set true to enable the Headless mechanism, for handling fetch events after app termination.
getter/setter pairinherited
- forceAlarmManager ↔ bool?
-
Android only: Set true to force Task to use Android
AlarmManager
mechanism rather thanJobScheduler
. Defaults tofalse
. Will result in more precise scheduling of tasks at the cost of higher battery usage.getter/setter pairinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- minimumFetchInterval ↔ int
-
The minimum interval in minutes to execute background fetch events.
getter/setter pair
- requiredNetworkType ↔ NetworkType?
-
Android only
Set detailed description of the kind of network your job requires.getter/setter pairinherited - requiresBatteryNotLow ↔ bool?
-
Android only
Specify that to run this job, the device's battery level must not be low.getter/setter pairinherited - requiresCharging ↔ bool?
-
Android only
Specify that to run this job, the device must be charging (or be a non-battery-powered device connected to permanent power, such as Android TV devices). This defaults to false.getter/setter pairinherited - requiresDeviceIdle ↔ bool?
-
Android only
When set true, ensure that this job will not run if the device is in active use.getter/setter pairinherited - requiresStorageNotLow ↔ bool?
-
Android only
Specify that to run this job, the device's available storage must not be low.getter/setter pairinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- startOnBoot ↔ bool?
-
Android only: Set
true
to initiate background-fetch events when the device is rebooted. Defaults tofalse
.getter/setter pairinherited - stopOnTerminate ↔ bool?
-
Android only: Set
false
to continue background-fetch events after user terminates the app. Default totrue
.getter/setter pairinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toMap(
) → Map< String, dynamic> -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited