getElementsByName function Null safety
Returns List of Figma2Flutter elements (Elem) with same FIgma name
.
Limit number of returned elements by specifying limit
Only currently active elements will be returned (i.e. elements displayed on current page)
Implementation
List<Elem> getElementsByName(String name, [int limit = 1]) {
List<Elem> results = [];
int cnt = 0;
for (int key in elementInstances.keys) {
if ((elementInstances[key]?.name == name ||
elementInstances[key]?.componentName == name) &&
elementInstances[key]?.widget.mounted == true) {
results.add(elementInstances[key]!);
cnt++;
}
if (cnt == limit) {
break;
}
}
return results;
}