Skip to content

Commit

Permalink
Reflect changes in fleaflet/flutter_map#1648
Browse files Browse the repository at this point in the history
  • Loading branch information
JaffaKetchup committed Sep 10, 2023
1 parent b669db8 commit 1b4a5c9
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions lib/flutter_map_cancellable_tile_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,23 @@ class _CNTPImageProvider extends ImageProvider<_CNTPImageProvider> {
final cancelToken = CancelToken();
unawaited(cancelLoading.then((_) => cancelToken.cancel()));

final Uint8List bytes;
try {
final response = await tileProvider._dio.get<Uint8List>(
useFallback ? fallbackUrl! : url,
cancelToken: cancelToken,
options: Options(
headers: tileProvider.headers,
responseType: ResponseType.bytes,
final codec = decode(
await ImmutableBuffer.fromUint8List(
(await tileProvider._dio.get<Uint8List>(
useFallback ? fallbackUrl! : url,
cancelToken: cancelToken,
options: Options(
headers: tileProvider.headers,
responseType: ResponseType.bytes,
),
))
.data!,
),
);
bytes = response.data!;

cancelLoading.ignore();
return codec;
} on DioException catch (err) {
if (CancelToken.isCancel(err)) {
return decode(
Expand All @@ -146,9 +152,6 @@ class _CNTPImageProvider extends ImageProvider<_CNTPImageProvider> {
if (useFallback || fallbackUrl == null) rethrow;
return _loadAsync(key, chunkEvents, decode, useFallback: true);
}

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

@override
Expand Down

0 comments on commit 1b4a5c9

Please sign in to comment.