【发布时间】:2021-09-30 06:56:11
【问题描述】:
当我通过 API 登录时,我得到了 User_id 值,我可以在控制台上打印,但我想在另一个屏幕上使用它。 那么如何将数据发送到另一个屏幕呢? // 第一个屏幕
Future postMethod() async {
var api = Uri.parse("https://demo.likemyfiles.com/DS/api/auth/otp");
Map mapeddate = {
'phone': _phone.text,
'otp': _otp.text,
};
final response = await http.post(api, body: mapeddate);
print(response.body);
var res = json.decode(response.body);
print(res['user_id']);
Navigator.pushNamed(context, StartActivity.id); //here i want to send the User_Id
}
//第二屏(Start Activity)在这个屏幕中有一个函数FetchData,我要在其中使用数据
Future fetchdata() async {
var url = await http.get(Uri.parse(
"http://demo.likemyfiles.com/DS/api/api_supervisor/supervisor/3")); //Instead of 3 i want
to use the User_Id variable
}
【问题讨论】:
标签: flutter flutter-layout flutter-web flutter-animation flutter-test