0

I need an empty list of map in which I wish to add maps one by one based on user actions. I do not know how many maps would be in the list. Before I had used this.

List<Map<String, dynamic> _items = new List<Map<String, dynamic>();

This doesn't seem to work anymore. I am coding in VS code and it shows error,

"List constructor not available when null safety is enabled".

So now what is the correct way of implementing this. I need to be able to add maps to this list using .add() method.

GunJack
  • 1,928
  • 2
  • 22
  • 35

1 Answers1

0

List<Map<String, dynamic> _items = <Map<String, dynamic>>[];

or List<Map<String, dynamic> _items = [];

Pathik Patel
  • 1,347
  • 1
  • 9
  • 22