update static method

Future<void> update({
  1. String? notificationTitle,
  2. String? notificationText,
  3. Function? callback,
})

Update foreground task.

Implementation

static Future<void> update({
  String? notificationTitle,
  String? notificationText,
  Function? callback,
}) async {
  // If the task is not running, the update function is not executed.
  if (!await isRunningTask) return;

  final options = Map<String, dynamic>();
  options['notificationContentTitle'] = notificationTitle;
  options['notificationContentText'] = notificationText;
  if (callback != null) {
    options['callbackHandle'] =
        PluginUtilities.getCallbackHandle(callback)?.toRawHandle();
  }

  _methodChannel.invokeMethod('updateForegroundService', options);
  _printMessage('FlutterForegroundTask updated.');
}