Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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.6.2+1

* Fixes a bug that prevented non-cloud styles from being applied.

## 0.6.2

* Adds `colorScheme` support for controlling cloud-based map brightness.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void main() {
textDirection: TextDirection.ltr,
);

testWidgets('cloudMapId present => mapId set & styles omitted', (
testWidgets('cloud mapId present => mapId set & styles omitted', (
WidgetTester tester,
) async {
const testMapConfig = MapConfiguration(mapId: 'test-cloud-map-id');
Expand All @@ -46,7 +46,7 @@ void main() {
mapId: 1, // Internal controller ID
streamController: stream,
widgetConfiguration: cfg(),
mapConfiguration: testMapConfig, // cloudMapId is set here
mapConfiguration: testMapConfig, // Cloud mapId is set here
);

controller.debugSetOverrides(
Expand All @@ -70,13 +70,13 @@ void main() {
expect(
captured!.styles == null || captured!.styles!.isEmpty,
isTrue,
reason: 'When cloudMapId is set, styles must not be applied.',
reason: 'When cloud mapId is set, styles must not be applied.',
);

controller.dispose();
});

testWidgets('no cloudMapId => styles applied', (WidgetTester tester) async {
testWidgets('no cloud mapId => styles applied', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(textDirection: TextDirection.ltr, child: SizedBox()),
);
Expand Down Expand Up @@ -113,13 +113,65 @@ void main() {
expect(
captured!.mapId,
anyOf(isNull, isEmpty),
reason: 'mapId should be empty/null when no Cloud Map is used.',
reason: 'mapId should be empty/null when no cloud mapId is used.',
);
expect(captured!.styles, isNotNull);
expect(
captured!.styles,
isNotEmpty,
reason: 'When cloudMapId is null, styles should be applied.',
reason: 'When cloud mapId is null, styles should be applied.',
);

controller.dispose();
});

testWidgets('empty cloud mapId is treated as no mapId', (
WidgetTester tester,
) async {
await tester.pumpWidget(
const Directionality(textDirection: TextDirection.ltr, child: SizedBox()),
);

final stream = StreamController<MapEvent<Object?>>();
addTearDown(() {
// Stream is closed by controller.dispose()
});

gmaps.MapOptions? captured;
final controller = GoogleMapController(
mapId: 2, // Internal controller ID
streamController: stream,
widgetConfiguration: cfg(),
mapConfiguration: const MapConfiguration(mapId: ''),
);

controller.debugSetOverrides(
setOptions: (gmaps.MapOptions options) {
captured = options;
},
);

final styles = <gmaps.MapTypeStyle>[
gmaps.MapTypeStyle()
..featureType = 'poi'
..elementType = 'labels',
];

controller.updateStyles(styles);

await tester.pump();

expect(captured, isNotNull);
expect(
captured!.mapId,
anyOf(isNull, isEmpty),
reason: 'mapId should be empty/null when no cloud mapId is used.',
);
expect(captured!.styles, isNotNull);
expect(
captured!.styles,
isNotEmpty,
reason: 'When cloud mapId is empty, styles should be applied.',
);

controller.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,15 @@ gmaps.MapOptions _configurationAndStyleToGmapsOptions(
options.fullscreenControl = false;
options.streetViewControl = false;

// Treat an empty mapId as null, as the app-facing package may pass it either
// way.
final String? mapId = configuration.mapId == '' ? null : configuration.mapId;
// If using cloud map, do not set options.styles
if (configuration.mapId == null) {
if (mapId == null) {
options.styles = styles;
}

options.mapId = configuration.mapId;
options.mapId = mapId;

final gmaps.ColorScheme? jsColorScheme = _gmapTypeColorSchemeForPluginColor(
configuration.colorScheme,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_maps_flutter_web
description: Web platform implementation of google_maps_flutter
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
version: 0.6.2
version: 0.6.2+1

environment:
sdk: ^3.9.0
Expand Down
Loading