lastWhere():
The last element that satisfies the given predicate
test
.An iterable that can access its elements directly may check its elements in any order (for example a list starts by checking the last element and then moves towards the start of the list).
The default implementation iterates elements in iteration order, checks
test(element)
for each, and finally returns that last one that matched.
Example:
void main() {
var num = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var lasteven;
lasteven = num.lastWhere((element) => element.isEven);
print(lasteven); //prints 10 which is the last even number in the list
}
10
Exited.