updateAvailableActions method

  1. @override
Future<void> updateAvailableActions(
  1. Set<MediaAction>? actions
)
override

Updates the set of media actions available in system controls.

Actions not in actions will be disabled (hidden or greyed out) in the notification and lock screen. Pass null to enable all actions.

Implementation

@override
Future<void> updateAvailableActions(Set<MediaAction>? actions) async {
  List<dynamic>? mappedActions;
  if (actions != null) {
    mappedActions = actions.map((a) {
      // Only Android currently supports custom visuals (labels/icons) for actions.
      // On other platforms, we just send the action name so the platform can
      // enable the corresponding native button if it exists.
      if (defaultTargetPlatform == TargetPlatform.android &&
          (a.customLabel != null || a.customIconResource != null)) {
        return a.toJson();
      }
      return a.name;
    }).toList();
  }
  await methodChannel.invokeMethod('updateAvailableActions', mappedActions);
}