getSpecificBook function

Future<Book> getSpecificBook(
  1. String id
)

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

Implementation

Future<Book> getSpecificBook(String id) 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>);
  } else {
    throw (result.body);
  }
}