1
0
mirror of https://github.com/flutter/samples.git synced 2026-05-13 10:27:09 +00:00

Simplify Unsplash response handling (#1077)

This commit is contained in:
Brett Morgan
2022-04-14 02:49:19 +10:00
committed by GitHub
parent 322f0628e6
commit 50731ab2fa
4 changed files with 20 additions and 18 deletions

View File

@@ -72,12 +72,7 @@ class Unsplash {
throw UnsplashException(apiError.errors!.join(', '));
}
return SearchPhotosResponse.fromJson(
// Per Response#body, if the Content-Type header is unknown, bodyBytes
// is interpreted as latin1. Unsplash returns utf8, but with no encoding
// specified in the Content-Type, so we must do it ourselves.
utf8.decode(response.bodyBytes),
);
return SearchPhotosResponse.fromJson(json.encode(body));
}
Future<Uint8List> download(Photo photo) async {