getSpecificBook function

Future<Book> getSpecificBook(
  1. String id, {
  2. bool reschemeImageLinks = false,
})

Get an specific book with its id. You can not add specific parameters to this.

Implementation

Future<Book> getSpecificBook(
  String id, {
  bool reschemeImageLinks = false,
}) async {
  assert(id.isNotEmpty, 'You must provide a valid id');
  final q = 'https://www.googleapis.com/books/v1/volumes/${id.trim()}';
  final result = await http.get(Uri.parse(q));
  if (result.statusCode == 200) {
    return Book.fromJson(
      jsonDecode(result.body) as Map<String, dynamic>,
      reschemeImageLinks: reschemeImageLinks,
    );
  } else {
    throw (result.body);
  }
}