0

I make a http request in my flutter app with a simple url api:

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;
  }
}

And the error message is:

err FormatException: Scheme not starting with alphabetic character (at character 1) ​https://reqres.in/api/users ^

enter image description here

I have switched to different channels of the flutter version and I don't know the solution, thanks!

Álvaro Agüero
  • 4,494
  • 1
  • 42
  • 39

1 Answers1

0

Try using

http.get(Uri.parse('​https://reqres.in/api/users'))
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
McWally
  • 217
  • 2
  • 5