Creating the app and connecting to the API with the HTTP library

Let's create a new Flutter app. We will call it Movies:

  1. The first thing to do is to open the pubspec.yaml file and add a dependency to the HTTP library, which we'll use to make HTTP requests. Please check the latest available version at https://pub.dev/packages/http. Add the http library under the flutter dependency, as follows:
dependencies:  flutter:    sdk: flutter  http: ^0.12.0+4
  1. Then, let's create a new file, called http_helper.dart, that we'll use to create the settings and methods that we'll use to connect to the web service. In the new file, let's import the HTTP library:
import 'package:http/http.dart' as http;

With the as http command, we are giving the library a ...

Get Flutter Projects 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.