How to create dynamic variable and how to add list of key,value pair values to it ?(Please read added comments)
Map sample = Map(); // creating sample named dynamic variable
List<TechData> data = [
{"title": 'Android', "date": '10/01/2019'},
{"title": 'Flutter', "date": '10/01/2019'},
{"title": 'Java', "date": '30/10/2019'},
];
sample['Android'] = [{}]; // initializing the dynamic variable
for (var i = 0; i < data.length; i++) { // trying to add value using .add()
if (data[i].title == 'Android') {
sample['Android'].add(data[i]);
}
}
when adding a value using .add() it causing an error as below.
Exception has occurred.
TypeError (type 'TechData' is not a subtype of type 'Map' of 'value')
Can anyone please provide any solution to solve this error?