getNameByIndex method

Future<String?> getNameByIndex(
  1. int index, {
  2. String? category,
})

Gets the name of the display by index 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?> getNameByIndex(int index, {String? category}) async {
  List<Display> displays = await getDisplays(category: category) ?? [];
  String? name;
  if (index >= 0 && index <= displays.length) name = displays[index].name;
  return name;
}