Answers for "map data in list in flutter"

1

flutter list to map

List list = [ ('a', (1,2)), ('b', (2,3)), ('c', (3,4)) ]

// Dart >= 2.3:
var result = { for (var v in list) v[0]: v[1] };

// Dart < 2.3
var result = Map.fromIterable(list, key: (v) => v[0], value: (v) => v[1]);
Posted by: Guest on August-10-2021
0

flutter map key/value

void main() {
  final testMap = {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5};
  for (final mapEntry in testMap.entries) {
    final key = mapEntry.key;
    final value = mapEntry.value;
    print('Key: $key, Value: $value');  // Key: a, Value: 1 ...
  }
}
Posted by: Guest on May-24-2021

Code answers related to "Dart"

Browse Popular Code Answers by Language