In order to create a responsive app that also targets the web, follow these steps:
- Create a new Flutter project, and call it books_universal.
- In the project's pubspec.yaml file, in the dependencies section, add the latest version of the http package:
http: ^0.13.0
-
In the lib directory of your project, create three new directories, called models, data, and screens.
-
In the models directory, create a new file, called book.dart.
-
In the book.dart file, create a class called Book, with the fields specified here:
class Book {
String id;
String title;
String authors;
String thumbnail;
String description;
}
- In the Book class, create a constructor that sets all the fields:
Book(this.id, this.title, this.authors, this.thumbnail,
this.description);
- Create a named factory constructor, called fromJson, that takes a Map and returns a Book, as shown in the code sample:
factory Book.fromJson(Map<String, dynamic> parsedJson) {
final String...