-2

I have a Map data.

Map<String , Map<String, List<int>>> data = {"value":{"it":[ 1666117800000,1666204200000,1666290600000 ],
  "mt":[1666463400000,1666549800000,1666636200000]}};

I want to print it and mt values form this Map.

  • 1
    `print(data['value']?['it']);` & `print(data['value']?['mt']);` – Tirth Patel Oct 31 '22 at 07:16
  • 1
    Does this answer your question? [Flutter/Dart: How to access a single entry in a map/object](https://stackoverflow.com/questions/53824755/flutter-dart-how-to-access-a-single-entry-in-a-map-object) – Bishan Oct 31 '22 at 07:20

3 Answers3

1
void main() {
  Map<String , Map<String, List<int>>> data = {"value":{"it":[ 1666117800000,1666204200000,1666290600000 ],
  "mt":[1666463400000,1666549800000,1666636200000]}};
  
  
  for (var it in data["value"]!["it"]!) {
    print(it);
  }
  print("");
  
  for (var mt in data["value"]!["mt"]!) {
    print(mt);
  }

}

Andrija
  • 1,534
  • 3
  • 10
1

accessing value from map is by using the key

 print(data['value']?['it']);
  print(data['value']?['mt']);

use ? means its nullable value

enter image description here

pmatatias
  • 3,491
  • 3
  • 10
  • 30
1
void main() {
  Map<String, Map<String, List<int>>> data = {
   "value": {
      "it": [1666117800000, 1666204200000, 1666290600000],
      "mt": [1666463400000, 1666549800000, 1666636200000]
    }
  };

  Map<String, List<int>>? _value = data['value'];

  print(_value);
  print(_value!['it']);
  print(_value!['mt']);
}
Hemal Moradiya
  • 1,715
  • 1
  • 6
  • 26