selectElementWhere<T extends PCanvasElement> method
Returns a list of PCanvasElement of type T
filtered by selector
.
Implementation
List<T> selectElementWhere<T extends PCanvasElement>(
bool Function(T elem) selector,
{bool recursive = false}) {
var elements = this.elements;
var sel = elements.whereType<T>().where(selector).toList();
if (!recursive) {
return sel;
}
var subList = elements
.whereType<PCanvasElementContainer>()
.expand((e) => e.selectElementWhere<T>(selector, recursive: true))
.toList();
return [...sel, ...subList];
}