Skip to content

Commit

Permalink
Fixed crash on uncaught "Invalid image data" exception (#1648)
Browse files Browse the repository at this point in the history
Co-authored-by: JaffaKetchup <[email protected]>
  • Loading branch information
s6o and JaffaKetchup authored Sep 10, 2023
1 parent 2616ef0 commit 06f75f0
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,19 @@ class FlutterMapNetworkImageProvider
ImageDecoderCallback decode, {
bool useFallback = false,
}) async {
final Uint8List bytes;
try {
bytes = await httpClient.readBytes(
Uri.parse(useFallback ? fallbackUrl ?? '' : url),
headers: headers,
return decode(
await ImmutableBuffer.fromUint8List(
await httpClient.readBytes(
Uri.parse(useFallback ? fallbackUrl ?? '' : url),
headers: headers,
),
),
);
} catch (_) {
if (useFallback || fallbackUrl == null) rethrow;
return _loadAsync(key, chunkEvents, decode, useFallback: true);
}

return decode(await ImmutableBuffer.fromUint8List(bytes));
}

@override
Expand Down

0 comments on commit 06f75f0

Please sign in to comment.