-
-
Notifications
You must be signed in to change notification settings - Fork 860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added cancellation support to TileProvider
and surrounding mechanisms
#1622
Conversation
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`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
TileProvider
that 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
TileProvider
that 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
TileProvider
interface, 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
.