Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

populating list with another list in flutter

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
   
    
       )

       ];
        }

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use .add like this

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

 for (var key in keylist) {
    _devchanged.add(Employeemodal(developer: key));
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading