Passing data to list from json in flutter | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

Passing data to list from json in flutter

I am trying to add data to a list in flutter i have a model class Visitors with a method getVisitors as below List<Visitor> _visitors=[] void getVisitors(id, name) { print(name) //to check if im receiving correct data var newVisitor=Visitor(id,name); _visitors.add(newVisitor ) } My function runs and prints a name on the the debug console but when i run _visitors. Length i get 0 which i don't understand because i thought _visitors.add(newVisitor) would push a mew object to the list }

7th Sep 2020, 7:30 PM
John Bryan
0 ответов