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 for the given mangaId,
  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'
  });
  try {
    return ReadChapters.fromJson(jsonDecode(response.body));
  } catch (e) {
    print(response);
    print(e.toString());
  }
}