getAllReadChapters function Null safety

Future<ReadChapters> getAllReadChapters(
  1. String token,
  2. String mangaId
)

Implementation

Future<ReadChapters> getAllReadChapters(String token, String mangaId) async {
  // get all read chapters in the given mangaIds,
  // please note it returns an http response since the response is not always of the same schema.
  var unencodedPath = '/manga/$mangaId/read';
  final uri = 'https://$authority/$unencodedPath?';
  var response = await http.get(Uri.parse(uri), headers: {
    HttpHeaders.contentTypeHeader: 'application/json',
    HttpHeaders.authorizationHeader: 'Bearer $token'
  });
  return ReadChapters.fromJson(jsonDecode(response.body));
}