how to save a list of data to a variable in flutter dart , please help me im new to flutter

16 views
Skip to first unread message

Navas jaseer

unread,
Mar 14, 2021, 6:24:49 AM3/14/21
to Flutter Development (flutter-dev)
hi,

var users = [
{id :3,name : adel,description: agent},{ id :4,name : anu,description: Manager,},
{id:5,name:arun,description:poen}
]

here i want to save each json object save in separate variable ,so i can acess it easily, how to do that

for (int i =0; i<users.length;i++)
{
 var descrip = users[i]['description'];
}

when i using this above loop method ,the variable saves only the last data in the list , im new to flutter , anyone know how to save this data to variable ,please help me


regards,
navas jaseeer

Suzuki Tomohiro

unread,
Mar 14, 2021, 8:52:40 AM3/14/21
to Navas jaseer, Flutter Development (flutter-dev)
Because the length is not fixed, you cannot do that. However, it’s likely that you already have what you want: “users[0]”, “users[1]”, ...
--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/c0fb6fbc-5ebe-4adb-b050-7898b0286b4fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages