Notification

When you listen for background location, a notification is displayed on Android. This methods allows you to update the notification.

Future<bool> updateBackgroundNotification({
  String? channelName,
  String? title,
  String? iconName,
  String? subtitle,
  String? description,
  Color? color,
  bool? onTapBringToFront,
})

iconName is the name of the icon to display. It should be in the res/drawable folder with the same name. By default, the library gives you a transparent icon.

Examples#

Updating the notification with the current location#

The notification will only appear on Android

_locationSubscription = onLocationChanged(inBackground: _inBackground)
    .listen((LocationData currentLocation) async {
        await updateBackgroundNotification(
            subtitle:
                'Location: ${currentLocation.latitude}, ${currentLocation.longitude}',
            onTapBringToFront: true,
        );
    }
);

...

_locationSubscription?.cancel();