Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[google_maps_flutter_web] show only single infoWindow #3224

Merged
merged 7 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.0+6

* Show only single infoWindow

## 0.1.0+5

* Update `package:google_maps` to `^3.4.5`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ class MarkersController extends GeometryController {
}

// InfoWindow...
MarkerController _markerController;

/// Shows the [InfoWindow] of a [MarkerId].
///
/// See also [hideMarkerInfoWindow] and [isInfoWindowShown].
void showMarkerInfoWindow(MarkerId markerId) {
_hideAllMarkerInfoWindow();
MarkerController markerController = _markerIdToController[markerId];
markerController?.showInfoWindow();
}
Expand Down Expand Up @@ -145,4 +147,10 @@ class MarkersController extends GeometryController {
markerId,
));
}

void _hideAllMarkerInfoWindow() {
_markerIdToController.values
.where((controller) => controller?.infoWindowShown)
.forEach((controller) => controller.hideInfoWindow());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: google_maps_flutter_web
description: Web platform implementation of google_maps_flutter
homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter
version: 0.1.0+5
version: 0.1.0+6

flutter:
plugin:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,33 @@ void main() {
expect(controller.markers[MarkerId('1')].infoWindowShown, isFalse);
});

testWidgets('only single InfoWindow is visible',
(WidgetTester tester) async {
final markers = {
Marker(
markerId: MarkerId('1'),
infoWindow: InfoWindow(title: "Title", snippet: "Snippet"),
),
Marker(
markerId: MarkerId('2'),
infoWindow: InfoWindow(title: "Title", snippet: "Snippet"),
),
};
controller.addMarkers(markers);

expect(controller.markers[MarkerId('1')].infoWindowShown, isFalse);

controller.showMarkerInfoWindow(MarkerId('1'));

expect(controller.markers[MarkerId('1')].infoWindowShown, isTrue);

controller.showMarkerInfoWindow(MarkerId('2'));

expect(controller.markers[MarkerId('2')].infoWindowShown, isTrue);

expect(controller.markers[MarkerId('1')].infoWindowShown, isFalse);
});

// https://github.com/flutter/flutter/issues/64938
testWidgets('markers with icon:null work', (WidgetTester tester) async {
final markers = {
Expand Down