Map future list flutter

Gopal Jangid

unread,
Jun 25, 2019, 3:12:04 PM6/25/19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Link
Report message as abuse
Sign in to report message as abuse
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Flutter Development [flutter-dev]
The whole code is pasted below please help.




import
'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';

void main[]{
runApp[
new MaterialApp[
title: 'app',
home: new Home[],
]
];
}

class Home extends StatefulWidget {
@override
_HomeState createState[] => _HomeState[];
}

class _HomeState extends State {
String _mySelection;
List _myJson = [{"id":0,"name":""},{"id":1,"name":"Test Practice"}];

Future getData[] async{
http.Response response = await http.get['//192.168.0.6/php/mssql_connection/get_username.php'];
print[response.body.toString[]];
return json.decode[response.body];
}

@override
Widget build[BuildContext context] {
return new Scaffold[
body: new Center[
child: new FutureBuilder[
future: getData[],
builder: [context,snapshot]{
if[snapshot.hasError] print[snapshot.error];
if[snapshot.hasData]{
return new DropdownButton[
isDense: true,
hint: new Text["Select"],
value: _mySelection,
onChanged: [String newValue] {

setState[[] {
_mySelection = newValue;
}];

print [_mySelection];
},
items: snapshot.data.map[[Map map] {
return new DropdownMenuItem[
value: map["cunm"].toString[],
child: new Text[
map["cunm"],
],
];
}].toList[],
];
}else{
return new CircularProgressIndicator[];
}
},
],
],
];
}
}

Video liên quan

Chủ Đề