flutter json object to to list for dropdown menu - json

I got json object from API and i have to show this as a dropdown.
Json response
{
"deliveryCharges": {
"_id": "607b156404fb0a0184db98fe",
"businessId": "607b14ef04fb0a0184db98e3",
"createdAt": "2021-04-17T17:05:40.546Z",
"updatedAt": "2021-04-18T10:16:13.633Z",
"__v": 0,
"deliveryZones": {
"Bangladesh": { // country dropdown item 1
"Mirpur": {. // city dropdown item 1
"deliveryCost": "50",
"status": true
}
},
"American Samoa": { // country dropdown item 2
"lost city": { // city dropdown item 2
"deliveryCost": "50",
"status": true
}
}
}
}
}
Here Bangladesh and American Samoa in country drop down
Here Mirpur and lost city in city drop down
I thing i have to change json object to array. But did not found good example.
Advanced thanks

Since
"deliveryZones": {
"Bangladesh": { // country dropdown item 1
"Mirpur": {. // city dropdown item 1
"deliveryCost": "50",
"status": true
}
},
"American Samoa": { // country dropdown item 2
"lost city": { // city dropdown item 2
"deliveryCost": "50",
"status": true
}
}
}
this object will be stored in Map Data structure
you can convert map keys to list
map.keys.toList()

First, declare two variables of an array.
List<String> countryList = [];
List<String> zoneList = [];
After that parse JSON data which is provided from API response.
Map<String, dynamic> decoded = json.decode(response);
for (var colour in decoded.keys) {
List<String>.from(decoded[colour]['deliveryZones'].keys.map((model) {
countryList.add(model);
}));
List<String>.from(decoded[colour]['deliveryZones']['Bangladesh'].keys.map((model) {
zoneList.add(model);
}));
}
Now print and show the output
print("country $countryList");
print("zoneList $zoneList");

So I have Created a sample Example Based on the json that you provided.
json you provided :
{
"deliveryCharges": {
"_id": "607b156404fb0a0184db98fe",
"businessId": "607b14ef04fb0a0184db98e3",
"createdAt": "2021-04-17T17:05:40.546Z",
"updatedAt": "2021-04-18T10:16:13.633Z",
"__v": 0,
"deliveryZones": {
"Bangladesh": {
"Mirpur": {
"deliveryCost": "50",
"status": true
}
},
"American Samoa": {
"lost city": {
"deliveryCost": "50",
"status": true
}
}
}
}
}
Based on the json I have Made an Example :
import 'package:flutter/material.dart';
import 'dart:convert';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
#override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
var _isLoading = false;
String countryValue;
List<String> countriesList = [];
List<String> cityList = [];
String cityValue;
#override
void initState() {
super.initState();
getData();
}
getData() async {
setState(() {
_isLoading = true;
});
String data =
await DefaultAssetBundle.of(context).loadString("json/parse.json");
var item = json.decode(data);
item.forEach((key, value) {
print(value["deliveryZones"]);
value["deliveryZones"].forEach((key, value) {
print(key);
countriesList.add(key);
value.forEach((key, value) {
print(key);
cityList.add(key);
});
});
});
setState(() {
_isLoading = false;
});
}
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("Users List "),
),
body: Container(
width: 300,
child: _isLoading
? CircularProgressIndicator()
: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
DropdownButtonHideUnderline(
child: DropdownButton(
hint: Text(
'Choose Country'), // Not necessary for Option 1
value: countryValue,
onChanged: (newValue) {
setState(() {
countryValue = newValue;
});
print(countryValue);
},
items: countriesList.map((String company) {
return DropdownMenuItem(
child: new Text(company),
value: company,
);
}).toList(),
),
),
DropdownButtonHideUnderline(
child: DropdownButton(
hint: Text('Choose City'), // Not necessary for Option 1
value: cityValue,
onChanged: (newValue) {
setState(() {
cityValue = newValue;
});
print(cityValue);
},
items: cityList.map((String company) {
return DropdownMenuItem(
child: new Text(company),
value: company,
);
}).toList(),
),
),
],
),
),
),
);
}
}
Let me know if it works.

Related

POST request body is not updating after inserting new value

I have a login field that when doing a post request it returns the http code. If I enter a valid phone number it returns 200. All good here. But when I try to reproduce an error message, it stores the previous phone number forever and I can't find a way to reset that field like it is in the beginning. Is this something to do with cache? Or is it about the variables state?
My Post body stored in global_variables.dart:
final Map<String, dynamic> loginBody = {
"type": "device",
"app_id": '1',
"email": "example#example.pt",
"country_id": '1',
"phone_number": phone.text, --> I want to reset the value here
"password": "secret"
};
login.dart
#override
void initState() {
super.initState();
success = false;
focusNode.addListener(() {
if (!focusNode.hasFocus) {
log(phone.text);
}
});
refreshValues();
}
#override
void dispose() {
focusNode.dispose();
phone.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
return !success
? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
maxLength: 9,
controller: phone,
focusNode: focusNode,
),
),
ElevatedButton(
onPressed: () async {
await login();
if (success) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: Colors.green,
content: Text(
loginSuccessful.toString(),
),
),
);
// ignore: use_build_context_synchronously
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const BreakdownScreen(),
),
);
refreshValues();
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: Colors.red,
content: Text(
loginUnsuccessful.toString(),
),
),
);
refreshValues();
}
},
child: const Text('Login'),
)
],
)
: Container();
}
void refreshValues() {
setState(
() {
loginSuccessful = "";
loginUnsuccessful = "";
phone.text = "";
},
);
}
Future<void> login() async {
try {
if (phone.text.length == 9) {
var response = await http.post(
Uri.parse("http://LOCAL_API/api/login"),
body: loginBody,
);
if (response.statusCode == 200) {
Map<String, dynamic> loginSuccess = json.decode(response.body);
Map<String, dynamic> loginTokenOnSuccess = json.decode(response.body);
loginToken = loginTokenOnSuccess['data'];
setState(
() {
loginSuccessful = loginSuccess['message'];
success = true;
// phone.text = "";
},
);
} else {
Map<String, dynamic> loginNoSuccess = json.decode(response.body);
setState(() {
success = false;
loginUnsuccessful = loginNoSuccess['message'];
});
}
}
} on Exception catch (e) {
log('ERRO ----- ${e.toString()},');
log(
json.encode(loginBody),
);
}
}
Output with invalid phone 333333333:
{(...)"phone_number":"333333333"}
Output with valid phone 22222222 (for example):
It only doesn't update after inserting a first value and stays like that until I hot reload the app.
{(...)"phone_number":"333333333"}
tl;dr: my phone_number field doesn't change after a second attempt
Solved it!
I had to construct the body directly on the POST function and remove it from the global_variables.dart file.
Future login() async {
try {
setState(() {});
if (phone.text.length == 9) {
var response = await http.post(
Uri.parse("http://LOCAL_API/api/login"),
body: {
"type": "device",
"app_id": '1',
"email": "example#mexample.com",
"country_id": '1',
"phone_number": phone.text,
"password": "secret"
},
);

Can I display datewise JSON data (ListView) in flutter?

I want to display JSON data on the date posted, there is a key value of date in the JSON string, Right Now I am printing the entire posted entries and it is really ugly?
I am currently using a flutter calendar weekly view which also disappears off the screen upon the day clicked. (runtime)
This is my Code where I am calling data
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:http/http.dart' as http;
import 'package:flutter/material.dart';
import 'package:flutter_calendar_week/flutter_calendar_week.dart';
class WeeklyData extends StatefulWidget {
_WeeklyDataState createState() => _WeeklyDataState();
}
var dt;
List data = [];
class _WeeklyDataState extends State<WeeklyData> {
void fetchData() async {
final uri = Uri.parse('My URL');
final header = {'Content-Type': 'application/json'};
final response = await http.get(uri, headers: header);
if (response.statusCode == 200) {
setState(() {
data = json.decode(response.body);
});
}
}
#override
void initState() {
super.initState();
fetchData();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
children: [
SizedBox(
height: 20,
),
CalendarWeek(
controller: CalendarWeekController(),
showMonth: true,
height: 100,
minDate: DateTime.now().add(Duration(days: -365)),
maxDate: DateTime.now().add(Duration(days: 365)),
onDatePressed: (DateTime datetime) {
dt = datetime;
},
),
SizedBox(
height: 20,
),
Text("$data"),
],
),
),
);
}
}
The data gets printed fine on the screen but it's too much I want to filter only the entry according to the day clicked on the calendar
[
{
"url": "http://157.90.55.200:8040/lover/1/",
"uuid": "bf47ddad-9362-4a12-af74-f8ad62883c60",
"raddress": "",
"pubkey": "",
"active": true,
"created": "2021-08-15T17:29:42.797000Z",
"updated": "2021-08-15T17:29:42.798000Z",
"day": 0,
"dslp": 0,
"dnpe": 0,
"cm": "string",
"love": 0,
"pain": "string",
"mood": "string",
"diet": "string",
"eln": "string",
"sreq": "string"
},
{
"url": "http://my url/lover/2/",
"uuid": "25254a18-e9c2-4489-b2f6-ff5174d07ee3",
"raddress": null,
"pubkey": null,
........
check and used grouplist package
GroupedListView<ModelClass, String>(
//physics: ScrollPhysics(),
shrinkWrap: true,
elements: listData,
groupBy: (ModelClass e) => '${e.created.subString(0,9)}',
groupSeparatorBuilder: (String groupByValue) => groupByValue!="null"? Container(
padding: EdgeInsets.only(left:30),
width: double.infinity,
color: Colors.grey.withOpacity(0.5),
child: Text(groupByValue)):Container(),
itemBuilder: (context, element) {
return Center(child: Text(element?.mode ?? ""));
},
order: GroupedListOrder.DESC,
)

How do I search through data in flutter app

I am new to flutter and I was following a tutorial that shows how to search through data. I cannot recreate that using my own example. I would like to know how to search through data in a ListView from this json data.
{
"success": "true",
"data": [
{
"id": 1,
"name": "football"
},
{
"id": 2,
"name": "rugby"
},
{
"id": 3,
"name": "basketball"
},
{
"id": 4,
"name": "hockey"
},
{
"id": 5,
"name": "tennis"
},
{
"id": 6,
"name": "golf"
}
]
}
Displayed using this code
if (snapshot.hasData) {
return ListView.builder(
itemCount: sports.games.length,
itemBuilder: (context, index) {
if (sports.games.length > 0) {
final x = sports.games[index];
final y = sports.games[index].id.toString();
return ListTile(
title: Text(y),
subtitle: Text(x.name),
);
}
},
);
}
},
First your JSON file will return as a Map, according to this answer at
Unhandled Exception: InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<dynamic>
for your problem, here is the solution. First you need create a model like this, can be place at separate file or can be place at same file too
class Sports {
int id;
String name;
Sports({
this.id,
this.name,
});
factory Sports.fromJson(Map<String, dynamic> json) {
return Sports(id: json['id'], name: json['name']);
}
}
than here it's the main.dart
import 'package:aberdeen/model.dart';
import 'package:flutter/material.dart';
import 'dart:convert';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
MyApp({Key key}) : super(key: key);
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyApp> {
TextEditingController controller = new TextEditingController();
List<Sports> array = [];
List<Sports> _filtered = [];
List<Sports> _null_filtered = [];
String jsonTest =
'{"success": "true","data": [{"id": 1,"name": "football"},{"id": 2,"name": "rugby"},{"id": 3,"name": "basketball"},{"id": 4,"name": "hockey"},{"id": 5,"name": "tennis"},{"id": 6,"name": "golf"}]}';
void initState() {
super.initState();
test();
}
void _alterfilter(String query) {
List<Sports> dummySearchList = [];
dummySearchList.addAll(_filtered);
if (query.isNotEmpty) {
List<Sports> dummyListData = [];
dummySearchList.forEach((item) {
if (item.name.contains(query)) { //if you want to search it order by id you can change item.name.contains to item.id.contains
dummyListData.add(item);
}
});
setState(() {
_filtered.clear();
_filtered.addAll(dummyListData); //dummyListData will place all the data that match at your search bar
});
return;
} else {
setState(() {
_filtered.clear();
_filtered.addAll(_null_filtered); //_null_filtered will place all the data if search bar was empty after enter a words
});
}
}
Future<Sports> test() async {
Map<String, dynamic> tagObjsJson = json.decode(jsonTest);
List<dynamic> data = tagObjsJson["data"];
setState(() {
for (Map Data in data) {
array.add(Sports.fromJson(Data));
}
_filtered.addAll(array);
_null_filtered.addAll(array);
for (int a = 0; a < _filtered.length; a++) {
print(_filtered[a].name);
}
});
}
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Container(
alignment: Alignment.center,
child: Container(
margin: const EdgeInsets.only(top: 50),
width: 300,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
border: Border.all(
width: 1,
color: Color.fromRGBO(11, 189, 180, 1),
style: BorderStyle.solid)),
child: TextField(
decoration: InputDecoration(
hintText: 'Search your data',
contentPadding: EdgeInsets.all(15),
border: InputBorder.none),
controller: controller,
onChanged: (value) {
_alterfilter(value);
},
),
),
),
],
),
Expanded(
child: Container(
margin: const EdgeInsets.all(20),
child: ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: _filtered.length,
itemBuilder: (context, index) {
if (array.length > 0) {
final x = _filtered[index];
final y = _filtered[index].id.toString();
return ListTile(
title: Text(y),
subtitle: Text(x.name),
);
}
},
),
))
],
),
),
));
}
}
Sorry mate if my english was very bad but tell me if you got confused

Can't decode/Parse Json type list<String> with this list<String> type Model in Dart

I wanted to create a drop down from json list. I am using app.quicktype.io to covert json to PODO (Plain Old dart Object)
Here is the My JSON data:
[
{
"country_name": "Andorra",
"alpha2_code": "AD",
"country_code": "376",
"states": [
{ "state_name": "Andorra la Vella" },
{ "state_name": "Canillo" }
]
},
]
And here is the PODO (Plain Old Dart Object) I created with app.quicktype.io:
class CountryDetailsModel {
CountryDetailsModel({
this.countryName,
this.alpha2Code,
this.countryCode,
this.states,
});
String countryName;
String alpha2Code;
String countryCode;
List<StateNames> states;
factory CountryDetailsModel.fromJson(Map<String, dynamic> json) =>
CountryDetailsModel(
countryName: json["country_name"],
alpha2Code: json["alpha2_code"],
countryCode: json["country_code"],
states: List<StateNames>.from(
json["states"].map((x) => StateNames.fromJson(x))),
);
Map<String, dynamic> toJson() => {
"country_name": countryName,
"alpha2_code": alpha2Code,
"country_code": countryCode,
"states": List<dynamic>.from(states.map((x) => x.toJson())),
};
}
class StateNames {
StateNames({
this.stateName,
});
String stateName;
factory StateNames.fromJson(Map<String, dynamic> json) => StateNames(
stateName: json["state_name"],
);
Map<String, dynamic> toJson() => {
"state_name": stateName,
};
}
You can copy paste run full code below
In working demo, simulate network delay with 3 seconds
You can use FutureBuilder and use return countryDetailsModelFromJson(jsonString);
code snippet
Future<List<CountryDetailsModel>> getHttp() async {
String jsonString = ...
return countryDetailsModelFromJson(jsonString);
}
...
FutureBuilder(
future: _future,
builder:
(context, AsyncSnapshot<List<CountryDetailsModel>> snapshot) {
...
return DropdownButton<CountryDetailsModel>(
//isDense: true,
hint: Text('Choose'),
value: _selectedValue,
icon: Icon(Icons.check_circle_outline),
iconSize: 24,
elevation: 16,
style: TextStyle(color: Colors.deepPurple),
underline: Container(
height: 2,
color: Colors.blue[300],
),
onChanged: (CountryDetailsModel newValue) {
setState(() {
_selectedValue = newValue;
});
},
items: snapshot.data
.map<DropdownMenuItem<CountryDetailsModel>>(
(CountryDetailsModel value) {
return DropdownMenuItem<CountryDetailsModel>(
value: value,
child: Text(value.countryName),
);
}).toList(),
);
}
}
})
working demo
full code
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
List<CountryDetailsModel> countryDetailsModelFromJson(String str) =>
List<CountryDetailsModel>.from(
json.decode(str).map((x) => CountryDetailsModel.fromJson(x)));
String countryDetailsModelToJson(List<CountryDetailsModel> data) =>
json.encode(List<dynamic>.from(data.map((x) => x.toJson())));
class CountryDetailsModel {
CountryDetailsModel({
this.countryName,
this.alpha2Code,
this.countryCode,
this.states,
});
String countryName;
String alpha2Code;
String countryCode;
List<StateNames> states;
factory CountryDetailsModel.fromJson(Map<String, dynamic> json) =>
CountryDetailsModel(
countryName: json["country_name"],
alpha2Code: json["alpha2_code"],
countryCode: json["country_code"],
states: List<StateNames>.from(
json["states"].map((x) => StateNames.fromJson(x))),
);
Map<String, dynamic> toJson() => {
"country_name": countryName,
"alpha2_code": alpha2Code,
"country_code": countryCode,
"states": List<dynamic>.from(states.map((x) => x.toJson())),
};
}
class StateNames {
StateNames({
this.stateName,
});
String stateName;
factory StateNames.fromJson(Map<String, dynamic> json) => StateNames(
stateName: json["state_name"],
);
Map<String, dynamic> toJson() => {
"state_name": stateName,
};
}
void main() => runApp(MyApp());
/// This Widget is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
#override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: MyStatefulWidget(),
),
);
}
}
class MyStatefulWidget extends StatefulWidget {
MyStatefulWidget({Key key}) : super(key: key);
#override
_MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
CountryDetailsModel _selectedValue;
Future<List<CountryDetailsModel>> _future;
Future<List<CountryDetailsModel>> getHttp() async {
String jsonString = '''
[
{
"country_name": "Andorra",
"alpha2_code": "AD",
"country_code": "376",
"states": [
{ "state_name": "Andorra la Vella" },
{ "state_name": "Canillo" },
{ "state_name": "Encamp" },
{ "state_name": "La Massana" },
{ "state_name": "Les Escaldes" },
{ "state_name": "Ordino" },
{ "state_name": "Sant Julia de Loria" }
]
},
{
"country_name": "Azerbaijan",
"alpha2_code": "AZ",
"country_code": "994",
"states": [
{ "state_name": "Abseron" },
{ "state_name": "Baki Sahari" },
{ "state_name": "Ganca" },
{ "state_name": "Ganja" },
{ "state_name": "Kalbacar" },
{ "state_name": "Lankaran" },
{ "state_name": "Mil-Qarabax" },
{ "state_name": "Mugan-Salyan" },
{ "state_name": "Nagorni-Qarabax" },
{ "state_name": "Naxcivan" },
{ "state_name": "Priaraks" },
{ "state_name": "Qazax" },
{ "state_name": "Saki" },
{ "state_name": "Sirvan" },
{ "state_name": "Xacmaz" }
]
}]
''';
return countryDetailsModelFromJson(jsonString);
}
#override
void initState() {
_future = getHttp();
super.initState();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: FutureBuilder(
future: _future,
builder:
(context, AsyncSnapshot<List<CountryDetailsModel>> snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
return Text('none');
case ConnectionState.waiting:
return Center(child: CircularProgressIndicator());
case ConnectionState.active:
return Text('');
case ConnectionState.done:
if (snapshot.hasError) {
return Text(
'${snapshot.error}',
style: TextStyle(color: Colors.red),
);
} else {
return DropdownButton<CountryDetailsModel>(
//isDense: true,
hint: Text('Choose'),
value: _selectedValue,
icon: Icon(Icons.check_circle_outline),
iconSize: 24,
elevation: 16,
style: TextStyle(color: Colors.deepPurple),
underline: Container(
height: 2,
color: Colors.blue[300],
),
onChanged: (CountryDetailsModel newValue) {
setState(() {
_selectedValue = newValue;
});
},
items: snapshot.data
.map<DropdownMenuItem<CountryDetailsModel>>(
(CountryDetailsModel value) {
return DropdownMenuItem<CountryDetailsModel>(
value: value,
child: Text(value.countryName),
);
}).toList(),
);
}
}
}));
}
}
Finally I found a solution.
Here is the Process:
List<CountryDetailsModel> countryDetails() {
List<Map> map = CountryData.countryData;
List<CountryDetailsModel> list =
map.map((json) => CountryDetailsModel.fromJson(json)).toList();
return list;
}
And for printing all countries:
countryDetails().
forEach((element) {
print(element.countryName);
});

Flutter JSON Nested to Lisview Builder

sorry i have searched on youtube and google but i'm still not getting any clue to parse JSON nested to listview builder.
my json result
[
{
"ID_Type": "1",
"Type": "Food",
"Item": [
{
"SLU_Number": "3",
"SLU_Name": "Food"
}
]
},
{
"ID_Type": "2",
"Type": "Beverages",
"Item": [
{
"SLU_Number": "1",
"SLU_Name": "Non Alcohol"
},
{
"SLU_Number": "2",
"SLU_Name": "Alchohol"
}
]
}
]
i want ID_Type, Type,Item (SLU_Number and SLU Name) throw all value to Listview.builder
thank you.
my code on flutter, i follow some code on youtube and that throw the value to List but i don't how to throw the value to Listview.builder
class Products {
final ID_Type;
final Name_Type;
final Items;
Products({
this.ID_Type,
this.Name_Type,
this.Items,
});
factory Products.fromJson(Map<String, dynamic> json) {
return Products(
ID_Type: json["ID_Type"],
Name_Type: json["Type"],
Items: Item.fromJson(json["Item"]),
);
}
}
class Item {
final SLU_Number;
final SLU_Name;
Item({
this.SLU_Number,
this.SLU_Name,
});
factory Item.fromJson(Map<String, dynamic> json) {
return Item(
SLU_Number: json["SLU_Number"],
SLU_Name: json["SLU_Name"],
);
}
}
here below is my Future to throw all the "json" result to List
//------------------------------Start Syntax for List SLU
final listslu = new List<ListSLU>();
final GlobalKey<RefreshIndicatorState> _refreshlistslu =
GlobalKey<RefreshIndicatorState>();
Future<void> ListSLUs() async {
listslu.clear();
setState(() {
loading = true;
});
try {
final response = await http.get(BaseUrl.ListSLU);
if (response.contentLength == 2) {
} else {
final data = jsonDecode(response.body);
data.forEach((api) {
final b = new ListSLU(
api['ID_Type'].toString(),
api['SLU_Number'].toString(),
api['SLU_Name'].toString(),
);
listslu.add(b);
print(api['SLU_Name'].toString());
});
}
} catch (e) {
print("Error List SLU :");
print(e);
}
}
//------------------------------End Syntax for List Type
after parsing all json result and then all value from json i throw to body
Expanded(
flex: 2,
child: ListView.builder(
itemCount: listslu.length,
itemBuilder: (context,i){
final z = listslu[i];
return GestureDetector(
onTap: (){
},
child: Container(
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Row(
children: <Widget>[
Text(z.SLU_Number +' - '+ z.SLU_Name),
],
),
],
)
],
),
),
);
}
)
),