selectElementByType<T extends PCanvasElement> method

List<T> selectElementByType<T extends PCanvasElement>({
  1. bool recursive = false,
})

Returns a list of PCanvasElement of type T.

Implementation

List<T> selectElementByType<T extends PCanvasElement>(
    {bool recursive = false}) {
  var elements = this.elements;

  var sel = elements.whereType<T>().toList();

  if (!recursive) {
    return sel;
  }

  var subList = elements
      .whereType<PCanvasElementContainer>()
      .expand((e) => e.selectElementByType<T>(recursive: true))
      .toList();

  return [...sel, ...subList];
}