skip to Main Content

In flutter by executing command HttpClient httpClient = HttpClient() returns this error :

Unsupported operation: Platform._version

There is solution to this problem?

3

Answers


  1. What package are you using to create the httpClient? Try replacing it with http: ^1.2.0, it works great.
    The second method, you can go from the console to the link to the problematic code and comment it out, this will also help.

    Login or Signup to reply.
  2. If you need a httpClient just:

    // import the lib with alias "http"
    import 'package:http/http.dart' as http;
    
    // declare and use the http client
    var client = http.Client();
    client.post(Uri.parse("https://www.google.com"));
    
    Login or Signup to reply.
  3. You’re presumably trying to use the HttpClient class from dart:io. dart:io can be used only for the Dart VM, not for the web. If you want something that can be used for both, then use package:http. Note that package:http is not a drop-in replacement for dart:io's HttpClient, although a lot of people consider package:http to be easier to use.

    If you require API-compatibility with dart:io‘s HttpClient, try package:universal_io.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search