Notification

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

Future<bool> changeNotificationOptions({
  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

final location = Location();
location.enableBackgroundMode(enable: true);
_locationSubscription = location.onLocationChanged
    .listen((LocationData currentLocation) async {
        await location.changeBackgroundOptions(
            subtitle:
                'Location: ${currentLocation.latitude}, ${currentLocation.longitude}',
            onTapBringToFront: true,
        );
    }
);

...

_locationSubscription?.cancel();