【发布时间】:2021-10-25 17:43:10
【问题描述】:
我想发送一个带有特定 ID 的请求,但我只能在从构建小部件中的上一个屏幕接收到该 ID 后才能获取该 ID
void gettingTime() async {
final response = await http.get(
Uri.parse('http://192.168.1.11/Backend/dateValide.php?id=$id'),);
print("StatusCodeDetail== ${response.statusCode}");
if (response.statusCode == 200 || response.statusCode == 201) {
setState(() {
dataListTime = json.decode(response.body); //we store the json data in a list
print("RESPONSE${response.body}");
});
}
else {
print("Error in loading from the server");
}
}
@override
void initState() {
gettingTime();
super.initState();
}
@override
Widget build(BuildContext context) {
dataMap=ModalRoute.of(context)?.settings.arguments as Map;//We recieve the data as a Map from the home screen
String id=dataMap["previousScreenData"]["ID_EXCURSION"];
【问题讨论】:
-
我感觉到一个问题来了。 :) 您没有提出任何问题,您想要解决的具体问题是什么?
-
您的意思是?小部件.yourParameter
标签: flutter widget parameter-passing