【问题标题】:FormatException: Scheme not starting with alphabetic character - Flutter Http RequestFormatException:方案不以字母字符开头 - Flutter Http Request
【发布时间】:2021-01-29 06:26:57
【问题描述】:

我用一个简单的 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("=> catchError getUsers $e");
      return null;
    });
  } on SocketException catch (e) {
    print("=> catch SocketException getUsers  $e");
    return null;
  } catch (e) {
    print("=> catch getUsers  $e");
    return null;
  }
}

错误信息是:

err FormatException:方案不以字母字符开头(在字符 1 处) https://reqres.in/api/users ^

已经切换到flutter版本的不同频道,不知道解决方法,谢谢!

【问题讨论】:

    标签: flutter http dart get flutter-channel


    【解决方案1】:

    尝试使用

    http.get(Uri.parse('​https://reqres.in/api/users'))
    

    【讨论】:

      猜你喜欢
      • 2020-08-03
      • 1970-01-01
      • 1970-01-01
      • 2021-02-26
      • 2020-03-08
      • 2019-09-04
      • 2021-11-30
      • 2018-07-27
      • 2019-10-29
      相关资源
      最近更新 更多