fetchThumbnail function

Future<(Uint8List?, String?)> fetchThumbnail(
  1. String uri
)

Fetches the specified thumbnail as an Uint8List of image file data (Uint8List, null) or (null, errorMessage)

Implementation

Future<(Uint8List?, String?)> fetchThumbnail(String uri) async {
  final response = await http.get(Uri.parse(uri));

  if (response.statusCode == 200) {
    return (response.bodyBytes, null);
  }
  else {
    return (null, 'Failed to load image. Status code: ${response.statusCode}');
  }
}