setOverrideTitleFromMediaItem method

Future<void> setOverrideTitleFromMediaItem(
  1. {required MediaItem item,
  2. required String? title}
)

Given a MediaItem, set its override display title. If the title is blank, the override title is cleared.

Implementation

Future<void> setOverrideTitleFromMediaItem({
  required MediaItem item,
  required String? title,
}) async {
  String key = getOverrideTitleKey(item);
  String? value;
  if (title != null) {
    String trimmedTitle = title.trim();
    if (trimmedTitle.isNotEmpty) {
      value = trimmedTitle;
    }
  }

  await setPreference<String?>(key: key, value: value);
}