Skip to content

Commit 74110db

Browse files
authored
feat: allow reassignment of MapController to FlutterMap multiple times (#1915)
1 parent 374672d commit 74110db

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Please consider [donating](https://docs.fleaflet.dev/supporters#support-us) or [
44

55
This CHANGELOG does not include every commit and/or PR - it is a hand picked selection of the most important ones. For a full list of changes, please check the GitHub repository releases/tags.
66

7-
## [7.0.2] - 2024/07/XX
7+
## [7.0.2] - 2024/07/02
88

99
> Note that this version causes a technically breaking change by removing `PolygonLayer.useDynamicUpdate` & `PolylineLayer.useDynamicUpdate`, introduced in v7.0.1. However, the implementations for these was broken on introduction, and their intended purpose no longer exists. Therefore, these should not have been used in any capacity, and should not affect any projects.
1010
@@ -13,6 +13,7 @@ Contains the following user-affecting bug fixes:
1313
- Fixed significant performance issues with `PolygonLayer` & `PolylineLayer` inadvertently introduced by v7.0.1 - [#1925](https://github.com/fleaflet/flutter_map/pull/1925) for [#1921](https://github.com/fleaflet/flutter_map/issues/1921)
1414
- Fixed bug where the holes of a `Polygon` would only appear if their winding direction was opposite to the direction of the `Polygon.points` - [#1925](https://github.com/fleaflet/flutter_map/pull/1925) for [#1924](https://github.com/fleaflet/flutter_map/issues/1924)
1515
- Relaxed constraint on 'package:logger' dependency - [#1922](https://github.com/fleaflet/flutter_map/pull/1922) for [#1916](https://github.com/fleaflet/flutter_map/issues/1916)
16+
- Allowed re-assignment of a `MapController` to a `FlutterMap` multiple times - [#1915](https://github.com/fleaflet/flutter_map/pull/1915) for [#1892](https://github.com/fleaflet/flutter_map/issues/1892)
1617

1718
## [7.0.1] - 2024/06/09
1819

example/lib/pages/map_controller.dart

+4-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ class MapControllerPage extends StatefulWidget {
1414
}
1515

1616
class MapControllerPageState extends State<MapControllerPage> {
17-
late final MapController _mapController;
17+
/// This example uses a global MapController instance to test if the
18+
/// controller can get applied to the map multiple times.
19+
static final MapController _mapController = MapController();
20+
1821
double _rotation = 0;
1922

2023
static const _london = LatLng(51.5, -0.09);
@@ -42,12 +45,6 @@ class MapControllerPageState extends State<MapControllerPage> {
4245
),
4346
];
4447

45-
@override
46-
void initState() {
47-
super.initState();
48-
_mapController = MapController();
49-
}
50-
5148
@override
5249
Widget build(BuildContext context) {
5350
return Scaffold(

lib/src/map/controller/map_controller_impl.dart

+1-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class MapControllerImpl extends ValueNotifier<_MapControllerState>
1616
implements MapController {
1717
final _mapEventStreamController = StreamController<MapEvent>.broadcast();
1818

19-
late final MapInteractiveViewerState _interactiveViewerState;
19+
late MapInteractiveViewerState _interactiveViewerState;
2020

2121
Animation<LatLng>? _moveAnimation;
2222
Animation<double>? _zoomAnimation;
@@ -338,11 +338,6 @@ class MapControllerImpl extends ValueNotifier<_MapControllerState>
338338
}
339339

340340
set options(MapOptions newOptions) {
341-
assert(
342-
newOptions != value.options,
343-
'Should not update options unless they change',
344-
);
345-
346341
final newCamera = value.camera?.withOptions(newOptions) ??
347342
MapCamera.initialCamera(newOptions);
348343

0 commit comments

Comments
 (0)