![](/img/trans.png)
[英]how to display cities in one dropdown based on selected state in other dropdown using json data in angular ionic?
[英]How to display selected month data from flutter dropdown selection using json
我尝试在 flutter 的下拉选择中显示选定月份数据,假设我是 select 一月,然后它在 json 甲酸盐中显示一月份的月份记录
String monthWiseGraph;
Future<String> getMonthlyGraphData() async {
String url = 'http://example.com/getAgentMonthGraph.php?month='+ monthWiseGraph ;
var response = await http.get(url);
return response.body;
}
Container(
height: 130,
width: 200,
padding: EdgeInsets.only(left: 30, top: 50),
child: Card(
// color: Colors.blueGrey,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(20),
bottomLeft: Radius.circular(20)),
side: BorderSide(color: Colors.black)),
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.only(top: 10, right: 20, left: 20),
child: DropdownButtonHideUnderline(
child: DropdownButton(
hint: Text("Monthly",
style:
TextStyle(color: Colors.black, fontSize: 25)),
value: monthWiseGraph,
icon: Icon(Icons.arrow_drop_down),
iconSize: 30,
elevation: 16,
style: TextStyle(color: Colors.black),
onChanged: (String monthNewValue) {
setState(
() {
monthWiseGraph = monthNewValue;
print(monthWiseGraph);
_showMonthlyAlert();
},
);
},
items: <String>[
'January',
'February',
.
.
'December'
].map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(
value,
style: TextStyle(
fontSize: 20,
),
),
);
}).toList(),
),
),
),
],
),
),
),
这是我一月份的数据
[
{
userId: "2",
name: "Manish",
total: "32"
},
{
userId: "3",
name: "Altaf",
total: "31"
}
]
这是我二月份的数据
[
{
userId: "4",
name: "Prathamesh",
total: "68"
},
{
userId: "7",
name: "Aniket",
total: "62"
},
]
Above image I display the selected month data When I select january from dropdown then it display january data from json like manish and altaf and when I select february it dipslay Prathamesh and Aniket data below is this is normal graph I am new to flutter
您必须将“jsonDecode(response.body)”放在变量中,或者只需更改“return”关键字。 然后您可以访问 JSON api 因为“JsonDecode”会将 JSON 数据更改为 ZC0ECD11C1D7A287401D148A23BBD7A2F8Z 语言为 ZC0ECD11C1D7A287401D148A23BBD7A2F8Z 语言。 确保“导入”所需的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.