Home > database >  populating list with another list in flutter
populating list with another list in flutter

Time:08-02

I have a list of object and I want populate the list with another dynamic list using for each , so when I try to do so only the last value from the dynamic list is added to the other list..

some one please help

 var keylist =[1,2] ;
 for (var key in keylist) {

_devchanged=[



   Employeemodal(
   
       developer: key
   
    
       )

       ];
        }

CodePudding user response:

You can use .add like this

var keylist =[1,2] ;
List<Employeemodal> _devchanged = [];

 for (var key in keylist) {
    _devchanged.add(Employeemodal(developer: key));
}
  • Related