getNameByDisplayId method

Future<String?> getNameByDisplayId(
  1. int displayId, {
  2. String? category,
})

Gets the name of the display by displayId of getDisplays.

Note that some displays may be renamed by the user. [category] The requested display category or null to return all displays. See [DISPLAY_CATEGORY_PRESENTATION]

@return The display's name. May be null.

Implementation

Future<String?> getNameByDisplayId(int displayId, {String? category}) async {
  List<Display> displays = await getDisplays(category: category) ?? [];
  for (final display in displays) {
    if (display.displayId == displayId) {
      return display.name;
    }
  }
  return null;
}