Last updated:
0 purchases
map to list
Extension on List to directly map a list, without calling toList.
Getting started #
Always chaining map and toList when you want to map a List is tiring, especially in a Flutter app development. Most of the time, we know we just want to map our list into another list, not into a lazy Iterable.
This simple extension simplify the process.
Usage #
Add package map_to_list into project dependencies:
dart pub add map_to_list
copied to clipboard
And import the package into your project file:
import 'package:map_to_list/map_to_list.dart';
copied to clipboard
Then you could call a single mapToList:
final list = [1, 2, 3, 4, 5];
final mapped = list.mapToList((value) => value * value);
copied to clipboard
Instead of always chaining map and toList:
final list = [1, 2, 3, 4, 5];
final squared = list.map((value) => value * value).toList();
copied to clipboard
Additional information #
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.