Skip to content

Commit

Permalink
feat: allow reassignment of MapController to FlutterMap multiple …
Browse files Browse the repository at this point in the history
…times (#1915)
  • Loading branch information
josxha authored Jul 2, 2024
1 parent 374672d commit 74110db
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Please consider [donating](https://docs.fleaflet.dev/supporters#support-us) or [

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.

## [7.0.2] - 2024/07/XX
## [7.0.2] - 2024/07/02

> 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.
Expand All @@ -13,6 +13,7 @@ Contains the following user-affecting bug fixes:
- 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)
- 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)
- 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)
- 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)

## [7.0.1] - 2024/06/09

Expand Down
11 changes: 4 additions & 7 deletions example/lib/pages/map_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ class MapControllerPage extends StatefulWidget {
}

class MapControllerPageState extends State<MapControllerPage> {
late final MapController _mapController;
/// This example uses a global MapController instance to test if the
/// controller can get applied to the map multiple times.
static final MapController _mapController = MapController();

double _rotation = 0;

static const _london = LatLng(51.5, -0.09);
Expand Down Expand Up @@ -42,12 +45,6 @@ class MapControllerPageState extends State<MapControllerPage> {
),
];

@override
void initState() {
super.initState();
_mapController = MapController();
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down
7 changes: 1 addition & 6 deletions lib/src/map/controller/map_controller_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MapControllerImpl extends ValueNotifier<_MapControllerState>
implements MapController {
final _mapEventStreamController = StreamController<MapEvent>.broadcast();

late final MapInteractiveViewerState _interactiveViewerState;
late MapInteractiveViewerState _interactiveViewerState;

Animation<LatLng>? _moveAnimation;
Animation<double>? _zoomAnimation;
Expand Down Expand Up @@ -338,11 +338,6 @@ class MapControllerImpl extends ValueNotifier<_MapControllerState>
}

set options(MapOptions newOptions) {
assert(
newOptions != value.options,
'Should not update options unless they change',
);

final newCamera = value.camera?.withOptions(newOptions) ??
MapCamera.initialCamera(newOptions);

Expand Down

0 comments on commit 74110db

Please sign in to comment.