【发布时间】:2021-05-18 06:58:32
【问题描述】:
当按下按钮时,我想发送 post 数据“1”或“2”int 值(http 包)。我该怎么做?
我的主页画面是这样的;
import 'package:http/http.dart' as http;
body: Container(
child: Column(
children: [
TextButton(
onPressed: () async {
var url = Uri.parse(
'http://test.com/control.php');
var response = await http.post(url, body: {'status': 2});
print('Response status: ${response.statusCode}');
print('Response body: ${response.body}');
},
child: Text('Open'),
),
TextButton(
onPressed: () async {
var url = Uri.parse(
'http://test.com/control.php');
var response = await http.post(url, body: {'status': 2});
print('Response status: ${response.statusCode}');
print('Response body: ${response.body}');
},
child: Text('Close'),
),
],
),
),
对不起我的英语,谢谢你的帮助!
【问题讨论】: