简体   繁体   中英

Create a map inside a list in Flutter/Dart

I want to create a MAP inside a list.

The result should be something like this

 [{date: 0, value: 0}, {date: 1, value: 0}, {date: 2, value: 0}, {date: 3, value: 0}, {date: 4, value: 0}]

This would be the easiest way-

 List a=[];

  for (int i = 0; i < 5; i++) {
    Map ab={};
    ab["date"]=i;
    ab["value"]=0;
    a.add(ab);
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM