Help us understand the problem. What is going on with this article?

Flutter DartでIndex付きのmapを簡単に行うExtension



forEach のほうがメモリ食うけど高速かなと思いforEachで書いてます。

extension IndexedMap<T, E> on List<T> {
  List<E> indexedMap<E>(E Function(int index, T item) function) {
    final list = <E>[];
    asMap().forEach((index, element) {
      list.add(function(index, element));
    return list;

// example
final List<int> list = [1, 2, 3];
list.indexedMap((index, element) => index.toString() + element.toString());
Developer | Firebase系YouTuber | プロトタイプ開発や新規サービス立ち上げが主な仕事 | ex) 実験, DeNA
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away