labelsViewerElementFromNums static method
Converts a List if labels to ViewerElement< List<Label<num>> >.
color
Optional color to render the element.
strokeSize
Optional stroke size to render the element.
Implementation
static ViewerElement<List<Label<num>>> labelsViewerElementFromNums(
List labels,
[Color? color,
int? strokeSize]) {
var mapped = labels.map((e) {
if (e is Map) {
return Label<num>(
e['label'] ?? e['title'] ?? e['name'] ?? e['id'],
parseNum(e['x'] ?? e['left'])!,
parseNum(e['y'] ?? e['top'])!,
parseNum(e['width'] ?? e['w'])!,
parseNum(e['height'] ?? e['h'])!);
} else if (e is List) {
return Label<num>(parseString(e[0])!, parseNum(e[1])!, parseNum(e[2])!,
parseNum(e[3])!, parseNum(e[4])!);
} else if (e is String) {
var list = parseStringFromInlineList(e)!;
var label = list.removeAt(0);
var ns = parseNumsFromList(list);
return Label<num>(label, parseNum(ns[0])!, parseNum(ns[1])!,
parseNum(ns[2])!, parseNum(ns[3])!);
} else {
throw ArgumentError('Invalid rectangles parameter: $labels');
}
}).toList();
return labelsViewerElement(mapped, color, strokeSize);
}