-
-
Notifications
You must be signed in to change notification settings - Fork 895
feat: add built-in caching & tile loading cancellation support #2082
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
Merged
Merged
Changes from 43 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
bafa5f0
Remove 'vector_math' dependency
JaffaKetchup cfd187b
Initial caching implementation
JaffaKetchup 6007304
Improved performance of persistent registry writer & format efficiency
JaffaKetchup 6fe737c
Refactored to re-enable web support
JaffaKetchup 25ebb25
Improved startup performance by not waiting for caching instance
JaffaKetchup b79cb07
Exposed `MapTileCachingManager` & `CachedMapTileMetadata`
JaffaKetchup 92c37cb
Added `MapCachingOptions.cacheKeyGenerator`
JaffaKetchup 985ba4c
Merge branch 'master' into caching
JaffaKetchup c1a8bb6
Reverted to waiting for manager instance to be created before returni…
JaffaKetchup bd5dfe7
Added size monitor
JaffaKetchup 2c38eb8
Major refactoring & renaming
JaffaKetchup e9c4465
Fixed linting issue
JaffaKetchup e67f7e4
Improved speed and efficiency of size limiter
JaffaKetchup 36d7268
Removed leftover debugging tools
JaffaKetchup 5fe9133
Improved documentation
JaffaKetchup 192860c
Switch to FlatBuffers instead of JSON
JaffaKetchup 9321d0c
Return number of tiles loaded from `isInitialised`
JaffaKetchup fd7a79b
Added call to `WidgetsFlutterBinding.ensureInitialized` internally
JaffaKetchup 0997c70
Drop default cache size limit to 800 MB
JaffaKetchup 5547146
Minor general improvements
JaffaKetchup db50851
Replace `catch (_)` with `on Exception`
JaffaKetchup 92452f6
Switched back to JSON from FlatBuffers
JaffaKetchup 92a60b1
Fixed size limiter
JaffaKetchup 3fe5adc
Minor improvement
JaffaKetchup 6078fe2
Fixed minor bug in example app
JaffaKetchup 37da3d4
Improved network tile image provider
JaffaKetchup c4b2bf4
Merge branch 'master' into caching
JaffaKetchup 2548269
Replace the JSON registry with a mechanism to store metadata within t…
JaffaKetchup 56bb2a6
Discard changes to example/lib/main.dart
JaffaKetchup 5c4899b
Fixed bug
JaffaKetchup 53e584f
Improved resilience to corruption
JaffaKetchup 16c1827
Improved resilience to corruption
JaffaKetchup 5f85c71
Fix unintended change
JaffaKetchup 3b350dc
Fixed minor bug
JaffaKetchup e6ba6d8
Minor improvements & bug fixes
JaffaKetchup 35d0607
Move default `tileKeyGenerator` implementation into a static util method
JaffaKetchup 8497204
Discard changes to lib/src/layer/tile_layer/tile_layer.dart
JaffaKetchup ac26dde
Merge branch 'master' into caching
JaffaKetchup 5c78329
Prevent fallback tiles from being cached
JaffaKetchup 507ff51
Expose `calculateStaleAt` via `CachedMapTileMetadata.fromHttpHeaders`…
JaffaKetchup 691341a
Merge branch 'master' into caching
JaffaKetchup 7d0a1a7
Added uninitialisation & cache deletion support
JaffaKetchup 1753866
Integrated abortable HTTP requests ('package:http ^1.5.0-beta') into …
JaffaKetchup 4489316
Apply 'terminating period' suggestions from code review
JaffaKetchup f519ee2
Rename "unneeded" & "unnecessary" to "obsolete"
JaffaKetchup 92dac52
Simplify image provider's `hashCode` implementation
JaffaKetchup c9ff03b
Fix formatting
JaffaKetchup 64753d5
Added reasoning for avoiding databases
JaffaKetchup 7c2e369
Added file format signature and version to cached tile specification
JaffaKetchup e2239dc
Convert `_SizeReducerTile` into an object
JaffaKetchup 1ebd84e
Merge branch 'master' into caching
JaffaKetchup e371fc8
Added TODO
JaffaKetchup 14132ad
Merge branch 'caching' of https://github.com/fleaflet/flutter_map int…
JaffaKetchup 4372897
Minor cache README refinement
JaffaKetchup ddc736e
Add `CachedMapTile` typedef
JaffaKetchup ace494d
Merge branch 'master' into caching
JaffaKetchup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| import 'package:flutter_map/flutter_map.dart'; | ||
| import 'package:flutter_map_cancellable_tile_provider/flutter_map_cancellable_tile_provider.dart'; | ||
| import 'package:http/http.dart'; | ||
| import 'package:http/retry.dart'; | ||
|
|
||
| final httpClient = RetryClient(Client()); | ||
|
|
||
| TileLayer get openStreetMapTileLayer => TileLayer( | ||
| urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', | ||
| userAgentPackageName: 'dev.fleaflet.flutter_map.example', | ||
| // Use the recommended flutter_map_cancellable_tile_provider package to | ||
| // support the cancellation of loading tiles. | ||
| tileProvider: CancellableNetworkTileProvider(), | ||
| tileProvider: NetworkTileProvider(httpClient: httpClient), | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import 'package:flutter/material.dart'; | ||
| import 'package:flutter_map/flutter_map.dart'; | ||
| import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart'; | ||
| import 'package:flutter_map_example/widgets/notice_banner.dart'; | ||
| import 'package:latlong2/latlong.dart'; | ||
|
|
||
| class AbortUnnecessaryRequestsPage extends StatefulWidget { | ||
| static const String route = '/abort_unnecessary_requests_page'; | ||
|
|
||
| const AbortUnnecessaryRequestsPage({super.key}); | ||
|
|
||
| @override | ||
| State<AbortUnnecessaryRequestsPage> createState() => | ||
| _AbortUnnecessaryRequestsPage(); | ||
| } | ||
|
|
||
| class _AbortUnnecessaryRequestsPage | ||
| extends State<AbortUnnecessaryRequestsPage> { | ||
| bool _abortingEnabled = true; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return Scaffold( | ||
| appBar: AppBar(title: const Text('Abort Unnecessary Requests')), | ||
| drawer: const MenuDrawer(AbortUnnecessaryRequestsPage.route), | ||
| body: Column( | ||
| children: [ | ||
| Padding( | ||
| padding: const EdgeInsets.symmetric(horizontal: 8), | ||
| child: Center( | ||
| child: Switch.adaptive( | ||
| value: _abortingEnabled, | ||
| onChanged: (value) => setState(() => _abortingEnabled = value), | ||
| ), | ||
| ), | ||
| ), | ||
| const NoticeBanner.recommendation( | ||
| text: 'Since v8.2.0, in-flight HTTP requests for tiles which are ' | ||
| 'no longer displayed are cancelled by default.', | ||
| url: 'https://docs.fleaflet.dev/layers/tile-layer/tile-providers', | ||
| sizeTransition: 870, | ||
| ), | ||
| Expanded( | ||
| child: FlutterMap( | ||
| options: MapOptions( | ||
| initialCenter: const LatLng(51.5, -0.09), | ||
| initialZoom: 5, | ||
| cameraConstraint: CameraConstraint.contain( | ||
| bounds: LatLngBounds( | ||
| const LatLng(-90, -180), | ||
| const LatLng(90, 180), | ||
| ), | ||
| ), | ||
| ), | ||
| children: [ | ||
| TileLayer( | ||
| key: ValueKey(_abortingEnabled), | ||
| urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', | ||
| userAgentPackageName: 'dev.fleaflet.flutter_map.example', | ||
| tileProvider: NetworkTileProvider( | ||
| abortUnneededRequests: _abortingEnabled, | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.