The http Package

To make GET requests we need to use the http package. You can find the http package on Dart Pub.[36]

Let’s start by creating a new Flutter app project using:

 $ flutter create xkcd_app

and installing the HTTP package by adding the following to pubspec.yaml:

 dependencies:
  http: ​"​​^0.12.0+1"

Run flutter packages get to download and install the package if you aren’t using the IDE plugins (which will do it automatically for you after you make changes to pubspec.yaml).

Using the http Package

The HTTP package can be used to make HTTP requests of all kinds.[37]

All of them are asynchronous, which means that, by default, they are ran in a separate thread without affecting the rest of the app’s ...

Get Programming Flutter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.