Version incompatibility in Flutter http operations

Nijat Namazzade
Sep 12, 2021

--

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 versionsin 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:

Thank you for your time.

--

--

Nijat Namazzade

I love applying responsive design principles and watching the things I created shrink into mobile screens and still look amazing.