getNameByDisplayId method

FutureOr<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

FutureOr<String?> getNameByDisplayId(int displayId,
    {String? category}) async {
  List<Display> displays = await getDisplays(category: category) ?? [];

  String? name;
  for (var element in displays) {
    if (element.displayId == displayId) name = element.name;
  }
  return name;
}