Version incompatibility in Flutter http operations
The http
the package changed slightly with its last versions. In this article, we’ll send a POST
request to an API endpoint with a URL.
For this, in the lecture, I’ll do this:
As of version 0.13.0 or higher of the http
package, URL can't be a string (i.e. plain text) anymore.
We have two options:
1) Use an older version of the HTTP package: E.g. set http: 0.12.2 or lower versions
in your pubspec.yaml
file
2) Convert the URL from a string to a “Url object” (and also change const
to final
):
For example, I recommend you to use this kind of code sample from now on and it should look like this:
Alternatively, we can also use this syntax: