You will create an app that connects to the Google Books API to retrieve a Flutter book's data from the web service, and you will show part of the result on the screen as shown in the screenshot:
The steps required in order to retrieve and show the data using a Future are outlined here:
- Create a new app and, in the pubspec.yaml file, add the html dependency (always make sure you are using the latest version, checking at https://pub.dev/packages/http/install):
dependencies:
flutter:
sdk: flutter
http: ^0.13.1
- The starting code in the main.dart file contains an ElevatedButton, a Text containing the result, and a CircularProgressIndicator. You can download the beginning code at https://github.com/PacktPublishing/Flutter-Cookbook/tree/master/chapter_07. Otherwise, type the following code:
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:http/http.dart&apos...