Flutter FormatException:方案不以字母字符开头-颤振Http请求
我使用一个简单的url api在我的颤振应用程序中发出http请求:Flutter FormatException:方案不以字母字符开头-颤振Http请求,flutter,http,dart,get,flutter-channel,Flutter,Http,Dart,Get,Flutter Channel,我使用一个简单的url api在我的颤振应用程序中发出http请求: Future<http.Response> getUsers() async { try { return await http .get('https://reqres.in/api/users') .timeout(const Duration(seconds: 10)) .catchError((e) { print("=&g
Future<http.Response> getUsers() async {
try {
return await http
.get('https://reqres.in/api/users')
.timeout(const Duration(seconds: 10))
.catchError((e) {
print("=> catchError getUsers $e");
return null;
});
} on SocketException catch (e) {
print("=> catch SocketException getUsers $e");
return null;
} catch (e) {
print("=> catch getUsers $e");
return null;
}
}
Future getUsers()异步{
试一试{
返回等待http
.get('https://reqres.in/api/users')
.超时(常数持续时间(秒:10))
.catchError((e){
打印(“=>catchError getUsers$e”);
返回null;
});
}关于SocketException捕捉(e){
打印(“=>catch SocketException getUsers$e”);
返回null;
}捕获(e){
打印(“=>catch getUsers$e”);
返回null;
}
}
错误消息是:
错误格式异常:方案不以字母字符开头(在字符1处)
https://reqres.in/api/users
^
我已经切换到颤振版本的不同频道,我不知道解决方案,谢谢 尝试使用
http.get(Uri.parse('https://reqres.in/api/users'))