Not getting all the record of username from json in flutter
106
Solution 1
If you want to have a separator, You can use ListView.separated
:
ListView.separated(
itemCount: _quakes.length,
itemBuilder: (context, index) {
return new ListTile(
title: new Text("${_quakes[index]['username']}"
, style: new TextStyle(fontSize: 19.2),),
subtitle: new Text("${_quakes[index]['email']}",
style: new TextStyle(fontSize: 14.9),),
);
},
separatorBuilder: (context, index) {
return Divider();
},
)
Solution 2
in your condition you have to do your itemCount * 2. it will work..
Author by
Saad Ebad
Updated on December 30, 2022Comments
-
Saad Ebad over 1 year
Hello everyone i am parsing a json file in which i am just fetching fields data "username" and "email" but i am not getting all values from the both fields instead i am getting only 5 values from the json file of "username" and "email" fields.
body: new Center( child: new ListView.builder(itemCount: _quakes.length, padding: const EdgeInsets.all(16.8), itemBuilder: (BuildContext context , int position) { if(position.isOdd ) return new Divider(); int index = position ~/ 2; return new ListTile( title: new Text("${_quakes[index]['username']}" , style: new TextStyle(fontSize: 19.2),), subtitle: new Text("${_quakes[index]['email']}", style: new TextStyle(fontSize: 14.9),), ); } ) )
-
Reza M almost 3 yearsBased on your code, you can only get half of
_quakes.length
because return divider in odd index. What's the problem exactly? -
Saad Ebad almost 3 yearsi want to get all values not half so what should i do ?
-