ancestors method

Iterable<Component> ancestors({
  1. bool includeSelf = false,
})
inherited

An iterator producing this component's parent, then its parent's parent, then the great-grand-parent, and so on, until it reaches a component without a parent.

Implementation

Iterable<Component> ancestors({bool includeSelf = false}) sync* {
  var current = includeSelf ? this : parent;
  while (current != null) {
    yield current;
    current = current.parent;
  }
}