fromIterables()
is a method in Dart that creates a Map
instance from an Iterable.
map.remove(key, value)
map
is the name of the map.
The map.fromIterables()
method requires the key
and value
to create a map
.
You must pass
key
andvalue
parameters to determine what should be thekey
andvalue
.
The Dart method map.fromIterables()
iterates over keys
and values
. It maps each element of the keys
to the corresponding elements of the values
.
If there are multiple elements with the same
key
, the last occurrence of akey
will be utilized.
The following code illustrates the fromIterable()
method’s use in Dart:
void main() {// Creating iterablesList<String> numbers = ['five', 'three', 'seven', 'one'];List<String> fruits = ['Apple', 'Orange', 'Lemon', 'Pawpaw'];// Creating a map from the iterables// using fromIterables() methodMap<String, String> map = new Map.fromIterables(numbers, fruits);print(map);}
Note: Both Iterables must have the same length.