File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
lib/src/layer/modern_tile_layer/tile_loader/bytes_fetchers/network/fetcher Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -304,9 +304,8 @@ class NetworkBytesFetcher implements SourceBytesFetcher<Iterable<String>> {
304304 );
305305
306306 // Server says nothing's changed - but might return new useful headers
307- if (! forceFromServer &&
308- cachedTile != null &&
309- response.statusCode == HttpStatus .notModified) {
307+ // This should usually only happen when `!forceFromServer`
308+ if (cachedTile != null && response.statusCode == HttpStatus .notModified) {
310309 late final R transformedCacheBytes;
311310 try {
312311 transformedCacheBytes = await transformer (cachedTile.bytes);
@@ -322,10 +321,13 @@ class NetworkBytesFetcher implements SourceBytesFetcher<Iterable<String>> {
322321 }
323322 }
324323
325- // Server says the image has changed - store it new
324+ // Server says the image has changed
326325 if (response.statusCode == HttpStatus .ok) {
326+ final resource = await transformer (bytes);
327+ // If the transformer fails, the error will be caught by an outer
328+ // try/catch block, and the bytes won't be put to the cache
327329 cachePut (bytes: bytes, headers: response.headers);
328- return await transformer (bytes) ;
330+ return resource ;
329331 }
330332
331333 // It's likely an error at this point
You can’t perform that action at this time.
0 commit comments