markChapterRead function Null safety

Future<Result> markChapterRead(
  1. String sessionToken,
  2. String chapterId
)

Mark a chapter identified by it's chapterId or uuid as READ

Implementation

Future<Result> markChapterRead(String sessionToken, String chapterId) async {
  var unencodedPath = '/chapter/$chapterId/read';
  final uri = 'https://$authority$unencodedPath';
  var response = await http.post(Uri.parse(uri),
      headers: {
        HttpHeaders.contentTypeHeader: 'application/json',
        HttpHeaders.authorizationHeader: 'Bearer $sessionToken'
      },
      body: jsonEncode({'id': '$chapterId'}));
  try {
    return Result.fromJson(jsonDecode(response.body));
  } on Exception {
    throw MangadexServerException(jsonDecode(response.body));
  }
}