close
0

Flutter listview with Map instead of List

avatar
asked 14-09-2021

2 Answers


0
return new ListView.builder(
  itemCount: values.length,
  itemBuilder: (BuildContext context, int index) {
    String key = values.keys.elementAt(index);
    return new Column(
      children: <Widget>[
        new ListTile(
          title: new Text("$key"),
          subtitle: new Text("${values[key]}"),
        ),
        new Divider(
          height: 2.0,
        ),
      ],
    );
  },
);
avatar
answered 14-09-2021

0
  map.forEach((key, value) {
        // here you can write your logic using "Value object",
       // make new object of your list view item and
       // add it to it's  builder list using 

       setState(() {
          _builderList.insert(0, itemObject);
       });

   });

or you can try

 final list = map.values.toList(growable: {true/false});
// play with your list
avatar
answered 14-09-2021