Learn about dart lastWhere() function with example. You may use this to find the last smallest or last biggest element in List or Queue.
void main(){
List<int> myList=[
1, 5, 3, 6, 2
];
var lastSmall = myList.lastWhere((e)=>e<4);
print(lastSmall);
}
It would be 2 as printed result. Because 2 is the smallest until the last element in the last query.
void main(){
List<int> myList=[
1, 7, 3, 5, 2,
];
var lastBig = myList.lastWhere((e)=>e>4);
print(lastBig);
}
here it will print 5 as the biggest one.