startLocationService static method

Future startLocationService({
  1. bool startOnBoot = false,
  2. int interval = 1000,
  3. int fastestInterval = 500,
  4. double distanceFilter = 0.0,
  5. bool forceAndroidLocationManager = false,
  6. LocationPriority priority = LocationPriority.priorityHighAccuracy,
  7. LocationCallback? backgroundCallback,
})

Start receiving location updated

Implementation

static Future<dynamic> startLocationService({
  bool startOnBoot = false,
  int interval = 1000,
  int fastestInterval = 500,
  double distanceFilter = 0.0,
  bool forceAndroidLocationManager = false,
  LocationPriority priority = LocationPriority.priorityHighAccuracy,
  LocationCallback? backgroundCallback,
}) async {
  var callbackHandle = 0;
  var locationCallback = 0;
  if (backgroundCallback != null) {
    callbackHandle = PluginUtilities.getCallbackHandle(callbackHandler)!.toRawHandle();
    try {
      locationCallback =
          PluginUtilities.getCallbackHandle(backgroundCallback)!
              .toRawHandle();
    } catch (ex, stack) {
      log('Error getting callback handle', error: ex, stackTrace: stack);
    }
  }

  return await _channel
      .invokeMethod('start_location_service', <String, dynamic>{
    'callbackHandle': callbackHandle,
    'locationCallback': locationCallback,
    'startOnBoot': startOnBoot,
    'interval': interval,
    'fastest_interval': fastestInterval,
    'priority': priority.index,
    'distance_filter': distanceFilter,
    'force_location_manager': forceAndroidLocationManager,
  });
}