请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

http.get填写的路径类型报错

final response=await http.get(‘http://www.devio.org/io/flutter_app/json/test_common_model.json’);
填写路径的时候报红线,说
The argument type ‘String’ can’t be assigned to the parameter type ‘Uri’

正在回答

1回答

亲说使用的http版本需要按照提示将url转成Uri进行传递:

import 'package:http/http.dart' as http;

var url = Uri.parse('https://example.com/whatsit/create');
var response = await http.post(url, body: {'name': 'doodle', 'color': 'blue'});
print('Response status: ${response.statusCode}');
print('Response body: ${response.body}');

print(await http.read('https://example.com/foobar.txt'));


1 回复 有任何疑惑可以回复我~
  • 提问者 段誉orz #1
    好的好的,非常感谢!
    回复 有任何疑惑可以回复我~ 2021-04-25 09:46:29
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信