getDisplays method
Gets all currently valid logical displays of the specified category.
When there are multiple displays in a category the returned displays are sorted of preference. For example, if the requested category is [DISPLAY_CATEGORY_PRESENTATION] and there are multiple secondary display then the displays are sorted so that the first display in the returned array is the most preferred secondary display. The application may simply use the first display or allow the user to choose.
category
The requested display category or null to return all displays.
@return An array containing all displays sorted by order of preference.
Implementation
FutureOr<List<Display>?> getDisplays({String? category}) async {
List<dynamic> origins = await jsonDecode(await _displayMethodChannel
?.invokeMethod(_listDisplay, category)) ??
[];
List<Display> displays = [];
for (var element in origins) {
final map = jsonDecode(jsonEncode(element));
displays.add(displayFromJson(map));
}
return displays;
}