Added cancellation support to TileProvider and surrounding mechanisms#1622
Added cancellation support to TileProvider and surrounding mechanisms#1622JaffaKetchup merged 4 commits intomasterfrom
TileProvider and surrounding mechanisms#1622Conversation
Cleanup `TileProvider` interface
|
Hi @JaffaKetchup, thanks for implementing this awesome feature! The cancellation works flawlessly. I haven't looked at the complete code yet but noticed two things: |
Close `NetworkTileProvider.httpClient` in `dispose`
TesteurManiak
left a comment
There was a problem hiding this comment.
LGTM, maybe wwe should add your code snippets as examples in the test app to showcase the cancellation mechanism 🤔
|
@TesteurManiak That's a good idea, I'll do that. Someone else said they might make a package, but it's easy enough just to make an example for. Just to double check, you're happy with the breaking refactoring and non-breaking cancellation support of the |
Yeah, deprecation messages are clear and the changes are not too intrusive 👍 |


Closes #1430. Note that this doesn't provide an implementation of a
TileProviderthat actually cancels HTTP requests, as this is currently unavailable without Dio (see #1430's thread for more info). It just implements the infrastructure necessary to allow an implementation.EDIT: flutter_map_cancellable_tile_provider has been released as part of the flutter_map organization, which includes a
TileProviderthat can cancel unnecessary HTTP requests.Without 'flutter_map_cancellable_tile_provider'
To test the cancellation support, install Dio, and try these code blocks on top of this branch. Then, run on the web, and open the browser's DevTools Network tab. Observe how some requests are marked as "(cancelled)". Note that this is more apparent with slower tile servers, so using the default OpenStreetMap tile server likely won't cause too many cancellations.
network_tile_provider.dart
network_image_provider.dart
Also involves a heavy (and breaking for a minority of implementations) cleanup of the
TileProviderinterface, to reduce the number of private methods, reduce the amount of code that must be overridden to achieve a custom behaviour, and reduce the scope of theTileLayer.