-
I'm looking for a way to query a first-matching element among descendants like .querySelector() in html. I'd appreciate if you could advise! Thanks 😊 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
When you call |
Beta Was this translation helpful? Give feedback.
-
@renggli |
Beta Was this translation helpful? Give feedback.
findAllElements
returns a lazyIterable
(see the documentation, there is noList
with all elements created). The iterable doesn't do anything until you actually iterate over the elements.When you call
first
on the iterator, it starts to traverse the tree until it finds the first matching element, aborts the traversal, and returns that element. Check out the Dart tutorial on Iterable collections for other operations.