Home > front end >  how to add map values in to a list in flutter
how to add map values in to a list in flutter

Time:01-14

i want to add values to a list like,

[{studAttId: null, divisionId: 4365eb0b-fb48-42f9-be4e-e9c1c695aeab, id: e49d6d0d-0036-417c-a0ff-330e51cb947d, forenoon: P, afternoon: P, admNo: 496, rollNo: null, name: A M MUHAMMED AFSAL, terminatedStatus: null},studAttId: null, divisionId: 4365eb0b-fb48-42f9-be4e-e9c1c695aeab, id: e49d6d0d-0036-417c-a0ff-330e51cb948d, forenoon: P, afternoon: P, admNo: 498, rollNo: null, name: MUHAMMED ADAN, terminatedStatus: null}]

CodePudding user response:

do this

yourList.add({
        'studAttId': 'null',
        'divisionId': '4365eb0b-fb48-42f9-be4e-e9c1c695aeab',
        'id': 'e49d6d0d-0036-417c-a0ff-330e51cb947d',
        'forenoon': 'P',
        'afternoon': 'P',
        'admNo': '496',
        'rollNo': 'null',
        'name': 'A M MUHAMMED AFSAL',
        'terminatedStatus': 'null'
      });

CodePudding user response:

First, preferably you can reformat the type of your map like this:

Map<String, dynamic> yourMap = { 
    'studAttId': 'null',
    'divisionId': '4365eb0b-fb48-42f9-be4e-e9c1c695aeab',
    'id': 'e49d6d0d-0036-417c-a0ff-330e51cb947d',
    }



 List<dynamic> yourList = []
 yourList.addAll(yourMap.values)
  • Related