Skip to content

Commit 3a48a21

Browse files
committed
[google_maps_flutter_web] Wrap map div in CSS reset (flutter/flutter#115216)
Wraps the map `div` in a `div` with `style.all = "initial"` to prevent red text due to a style set on `body` by Flutter.
1 parent 6da73be commit 3a48a21

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/google_maps_flutter/google_maps_flutter_web/lib/google_maps_flutter_web.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import 'dart:html';
1010
import 'dart:js_util';
1111

1212
import 'package:flutter/foundation.dart';
13-
import 'package:flutter/material.dart';
13+
import 'package:flutter/material.dart' hide Element;
1414
import 'package:flutter/services.dart';
15-
import 'package:flutter/widgets.dart';
15+
import 'package:flutter/widgets.dart' hide Element;
1616
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
1717
import 'package:google_maps/google_maps.dart' as gmaps;
1818
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';

packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart

+9-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ class GoogleMapController {
4141

4242
ui.platformViewRegistry.registerViewFactory(
4343
_getViewType(mapId),
44-
(int viewId) => _div,
44+
(int viewId) => DivElement()
45+
// Wrap the map div in a CSS reset for consistent styling.
46+
// Having this on the map div itself seems to make it fail to render.
47+
..style.setProperty('all', 'initial')
48+
// However, we do still need to set these to keep Flutter from logging a
49+
// complaint.
50+
..style.width = '100%'
51+
..style.height = '100%'
52+
..children = <Element>[_div],
4553
);
4654
}
4755

0 commit comments

Comments
 (0)