【发布时间】:2020-12-21 13:30:09
【问题描述】:
我正在使用以下函数在按下按钮时调用,它会更新后端服务器中的数据。如果该功能成功,我希望页面重新加载并在页面上更新新数据。我应该如何在 Flutter 中做到这一点?
approvalbutton() async {
var jsonResponse = null;
var response = await http.post(approvalapiurl, body: data);
if (response.statusCode == 200) {
jsonResponse = json.decode(response.body);
print('Response status: ${response.statusCode}');
print('Response body: ${response.body}');
String errorcheck = jsonResponse['error'];
if (errorcheck == "false") {
print('success');
}
else {
print('failed');
}
}
}
【问题讨论】:
标签: json flutter dart page-refresh