Рет қаралды 5,323
In this video, you can find 2 different methods to get the index value of your current map element.
The first method exemplified is the simplest one. You just need to use the indexOf method on the original list and then you use the element given to you by the map as the parameter.
The second method is by extending the Iterable and creating your own customized version of the map function.
Hope this can help someone out there!
INDEXED MAP CODE TO COPY (KZbin doesn't allow angled brackets in the description, so I replaced them with the asterisk *):
extension IndexedIterable*E* on Iterable*E* {
Iterable*T* indexedMap*T* (T Function(E element, int index) f) {
var index = 0;
return map((e) =* f(e, index++));
}
}
00:00 - Intro
01:05 - Code Explanation
02:30 - The indexOf Method
03:30 - The Custom Indexed Map Method
06:28 - Like & Subscribe
06:52 - Flutter Mentor Out
#dart #maps #index
Credits:
OUTRO SONG:
Mitsubachi by Smith The Mister smiththemister.bandcamp.com
Smith The Mister bit.ly/Smith-The-Mister-YT
Free Download / Stream: bit.ly/mitsubachi
Music promoted by Audio Library • Mitsubachi - Smith The...