【发布时间】:2021-03-09 23:42:55
【问题描述】:
随着新的更新,一些 HTTP 功能发生了变化。这个功能以前可以用,现在不行了。有人可以解释发生了什么变化吗?
import 'package:http/http.dart';
void getData() async {
Response response = await get('https://jsonplaceholder.typicode.com/todos/1');
Map data = JsonDecode(responce.body);
print(data);
}
lib/pages/loading.dart:24:37: Error: The argument type 'String' can't be assigned to the parameter type 'Uri'.
- 'Uri' is from 'dart:core'.
Response response = await get('https://jsonplaceholder.typicode.com/todos/1');
【问题讨论】:
-
该代码中有一些潜在的错误,您能显示您感兴趣的错误消息吗?
-
lib/pages/loading.dart:24:37:错误:参数类型“字符串”不能分配给参数类型“Uri”。 - 'Uri' 来自 'dart:core'。响应 response = await get('jsonplaceholder.typicode.com/todos/1'); ^
-
试试下面的代码......
标签: flutter flutter-http