From 800639f8bb48e3b411d0c975049f965604ca7383 Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Tue, 19 Jul 2022 09:56:00 +0100 Subject: [PATCH 1/7] Added keep alive functionality (alongside https://github.com/fleaflet/flutter_map/pull/1293) --- lib/flutter_map.dart | 9 +++++++++ lib/src/map/flutter_map_state.dart | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/flutter_map.dart b/lib/flutter_map.dart index 7b198a5b3..f96424fc2 100644 --- a/lib/flutter_map.dart +++ b/lib/flutter_map.dart @@ -291,6 +291,14 @@ class MapOptions { /// would represent the full extent of the map, so no gray area outside of it. final LatLngBounds? maxBounds; + /// Flag to enable the built in keep alive functionality + /// + /// If the map is within a complex layout, such as a [ListView] or [PageView], + /// the map will reset to it's inital position after it appears back into view. + /// To ensure this doesn't happen, enable this flag to prevent the [FlutterMap] + /// widget from rebuilding. + final bool keepAlive; + _SafeArea? _safeAreaCache; double? _safeAreaZoom; @@ -334,6 +342,7 @@ class MapOptions { this.swPanBoundary, this.nePanBoundary, this.maxBounds, + this.keepAlive = false, }) : center = center ?? LatLng(50.5, 30.51), assert(rotationThreshold >= 0.0), assert(pinchZoomThreshold >= 0.0), diff --git a/lib/src/map/flutter_map_state.dart b/lib/src/map/flutter_map_state.dart index 0d63caab4..13f5bd123 100644 --- a/lib/src/map/flutter_map_state.dart +++ b/lib/src/map/flutter_map_state.dart @@ -9,7 +9,8 @@ import 'package:flutter_map/src/map/map.dart'; import 'package:flutter_map/src/map/map_state_widget.dart'; import 'package:positioned_tap_detector_2/positioned_tap_detector_2.dart'; -class FlutterMapState extends MapGestureMixin { +class FlutterMapState extends MapGestureMixin + with AutomaticKeepAliveClientMixin { final List> groups = >[]; final _positionedTapController = PositionedTapController(); @@ -73,6 +74,7 @@ class FlutterMapState extends MapGestureMixin { @override Widget build(BuildContext context) { _disposeStreamGroups(); + super.build(context); return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { final hasLateSize = mapState.hasLateSize(constraints); @@ -230,4 +232,7 @@ Can't find correct layer for $options. Perhaps when you create your FlutterMap y options: new MapOptions(plugins: [MyFlutterMapPlugin()])""")); } + + @override + bool get wantKeepAlive => options.keepAlive; } From a9dc27686574f064aee62effa6316a40dac657cd Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Tue, 19 Jul 2022 09:59:43 +0100 Subject: [PATCH 2/7] Updated package version Updated CHANGELOG --- CHANGELOG.md | 21 ++++++++++++++++++++- pubspec.yaml | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4b686d5d..30229d7a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,25 @@ # Changelog -## [2.0.0] - 2022/XX/XX +## [2.1.0] - 2022/XX/XX + +Contains the following additions/removals: + +- Added built in keep alive functionality + +Contains the following bug fixes: + +- Remove a class of `LateInitializationError`s by reworking `MapController` lifecycle - [#1293](https://github.com/fleaflet/flutter_map/pull/1293) for [#1288](https://github.com/fleaflet/flutter_map/issues/1288) + +In other news: + +- None + +Many thanks to these contributors (in no particular order): + +- @Zverik +- ... and all the maintainers + +## [2.0.0] - 2022/07/11 Contains the following additions/removals: diff --git a/pubspec.yaml b/pubspec.yaml index 17d0cc92d..220dfd850 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_map description: A versatile mapping package for Flutter, based off leaflet.js, that's simple and easy to learn, yet completely customizable and configurable. -version: 2.0.0 +version: 2.1.0 repository: https://github.com/fleaflet/flutter_map documentation: https://docs.fleaflet.dev From 2b40ceec499681b6d6f527b7dfb1512d0fc7c707 Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Tue, 19 Jul 2022 10:03:49 +0100 Subject: [PATCH 3/7] Updated CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30229d7a9..aa78b5074 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ Contains the following additions/removals: -- Added built in keep alive functionality +- Added built in keep alive functionality - [#1312](https://github.com/fleaflet/flutter_map/pull/1293) Contains the following bug fixes: From accdbf86e7834e0535167ed4ec411a09b3b0bb7d Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Wed, 20 Jul 2022 09:51:37 +0100 Subject: [PATCH 4/7] Updated CHANGELOG with https://github.com/fleaflet/flutter_map/pull/1303 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa78b5074..474589a17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Contains the following additions/removals: - Added built in keep alive functionality - [#1312](https://github.com/fleaflet/flutter_map/pull/1293) +- Added disposal of `AnimationController` before it is reassigned - [#1303](https://github.com/fleaflet/flutter_map/pull/1303) Contains the following bug fixes: @@ -17,6 +18,7 @@ In other news: Many thanks to these contributors (in no particular order): - @Zverik +- @rbellens - ... and all the maintainers ## [2.0.0] - 2022/07/11 From 4f78fecc94b05bedceccf70873df0833b14153e0 Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Wed, 20 Jul 2022 16:45:45 +0100 Subject: [PATCH 5/7] Updated CHANGLOG to reflect recent merges --- CHANGELOG.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 474589a17..6c438bc3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,15 @@ Contains the following additions/removals: -- Added built in keep alive functionality - [#1312](https://github.com/fleaflet/flutter_map/pull/1293) +- Added built in keep alive functionality - [#1312](https://github.com/fleaflet/flutter_map/pull/1312) - Added disposal of `AnimationController` before it is reassigned - [#1303](https://github.com/fleaflet/flutter_map/pull/1303) +- Added better polar projection support and example - [#1295](https://github.com/fleaflet/flutter_map/pull/1295) +- Added stroke cap and stroke join options to `Polygon`s - [#1295](https://github.com/fleaflet/flutter_map/pull/1295) Contains the following bug fixes: -- Remove a class of `LateInitializationError`s by reworking `MapController` lifecycle - [#1293](https://github.com/fleaflet/flutter_map/pull/1293) for [#1288](https://github.com/fleaflet/flutter_map/issues/1288) +- Removed a class of `LateInitializationError`s by reworking `MapController` lifecycle - [#1293](https://github.com/fleaflet/flutter_map/pull/1293) for [#1288](https://github.com/fleaflet/flutter_map/issues/1288) +- Improved performance during painting `Polygon`s - [#1295](https://github.com/fleaflet/flutter_map/pull/1295) In other news: @@ -19,6 +22,7 @@ Many thanks to these contributors (in no particular order): - @Zverik - @rbellens +- @JosefWN - ... and all the maintainers ## [2.0.0] - 2022/07/11 From 0622af80a105fee4820e51f173ce52aa731e0a0a Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Thu, 21 Jul 2022 10:38:23 +0100 Subject: [PATCH 6/7] Improved Bug Report Template --- .github/ISSUE_TEMPLATE/bug-report.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yaml b/.github/ISSUE_TEMPLATE/bug-report.yaml index 5f62b2db9..87454f1d1 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yaml +++ b/.github/ISSUE_TEMPLATE/bug-report.yaml @@ -36,6 +36,11 @@ body: If you do not include any information here, it will take longer for us to verify your issue. placeholder: Text automatically formatted as Dart code, on submission render: dart + - type: textarea + id: solution + attributes: + label: Do you have a potential solution? + description: "If so, please detail it: it will make it quicker for us to fix the issue" - type: textarea id: additional-info attributes: @@ -101,7 +106,7 @@ body: required: true - label: I am using the [latest stable version](https://pub.dev/packages/flutter_map) of this package required: true - - label: I have checked the [Common Issues](https://docs.fleaflet.dev/usage/common-issues) documentation page + - label: I have checked the FAQs section on the documentation website required: true - label: I have checked for similar issues which may be duplicates required: true From 578bc831a42c502fc6b9b63f5b1ec5afcf1d6cb5 Mon Sep 17 00:00:00 2001 From: JaffaKetchup Date: Mon, 25 Jul 2022 16:46:09 +0100 Subject: [PATCH 7/7] Fixed null-safety bug --- .../tile_provider/network_no_retry_image_provider.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/layer/tile_layer/tile_provider/network_no_retry_image_provider.dart b/lib/src/layer/tile_layer/tile_provider/network_no_retry_image_provider.dart index 059add3bf..44d6e05a1 100644 --- a/lib/src/layer/tile_layer/tile_provider/network_no_retry_image_provider.dart +++ b/lib/src/layer/tile_layer/tile_provider/network_no_retry_image_provider.dart @@ -90,11 +90,13 @@ class FMNetworkNoRetryImageProvider return decode(bytes); } catch (e) { scheduleMicrotask(() { - PaintingBinding.instance.imageCache.evict(key); + _ambiguate(PaintingBinding.instance.imageCache)?.evict(key); }); rethrow; } finally { chunkEvents.close(); } } + + T? _ambiguate(T? value) => value; }