Я недавно добавил веб-поддержку в свое приложение, но проблема была в Google Maps, я использую flutter_google_maps для android и IOS, но для Интернета у меня возникли некоторые проблемы: я использовал плагин google_map для Интернета, и он работал для сети, но когда я пытаюсь запустить проект на мобильном устройстве, появляется ошибка, что «dart: html» не найден. Я искал ошибку, нашел библиотеку universal_ html, которая также не работала для меня.
это мой код:
// import 'package:universal_html/html.dart' as html;
import 'dart:html';
import 'package:flutter/material.dart';
import 'package:google_maps/google_maps.dart';
import 'dart:ui' as ui;
class GoogleMap extends StatelessWidget {
@override
Widget build(BuildContext context) {
String htmlId = "7";
// ignore: undefined_prefixed_name
ui.platformViewRegistry.registerViewFactory(htmlId, (int viewId) {
final myLatlng = LatLng(25.373327, 55.399455);
// another location
final myLatlng2 = LatLng(1.4521, 103.9198);
final mapOptions = MapOptions()
..zoom = 14.4746
..center = LatLng(25.373327, 55.399455);
final elem = DivElement()
..id = htmlId
..style.width = "100%"
..style.height = "100%"
..style.border = 'none';
final map = GMap(elem, mapOptions);
final marker = Marker(MarkerOptions()
..position = myLatlng
..map = map
..title = 'Hello World!'
..label = 'h'
..icon =
'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png');
// Another marker
Marker(
MarkerOptions()
..position = myLatlng2
..map = map,
);
final infoWindow =
InfoWindow(InfoWindowOptions()..content = contentString);
marker.onClick.listen((event) => infoWindow.open(map, marker));
return elem;
});
return HtmlElementView(viewType: htmlId);
}
}
var contentString = '<div id="content">' +
'<div id="siteNotice">' +
'</div>' +
'<h1 id="firstHeading" class="firstHeading">Uluru</h1>' +
'<div id="bodyContent">' +
'<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' +
'sandstone rock formation in the southern part of the ' +
'Northern Territory, central Australia. It lies 335 km (208 mi) ' +
'south west of the nearest large town, Alice Springs; 450 km ' +
'(280 mi) by road. Kata Tjuta and Uluru are the two major ' +
'features of the Uluru - Kata Tjuta National Park. Uluru is ' +
'sacred to the Pitjantjatjara and Yankunytjatjara, the ' +
'Aboriginal people of the area. It has many springs, waterholes, ' +
'rock caves and ancient paintings. Uluru is listed as a World ' +
'Heritage Site.</p>' +
'<p>Attribution: Uluru, <a href="https://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">' +
'https://en.wikipedia.org/w/index.php?title=Uluru</a> ' +
'(last visited June 22, 2009).</p>' +
'</div>' +
'</div>';
и это журнал:
Launching lib\main.dart on Mi 9 SE in debug mode...
Compiler message:
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/google_maps_src.dart:19:8: Error: Not found: 'dart:html'
import 'dart:html' show Node, Document;
^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/js_wrapping-0.5.0/lib/js_wrapping.dart:9:8: Error: Not found: 'dart:js'
import 'dart:js';
^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/js_wrapping-0.5.0/lib/js_wrapping.dart:11:1: Error: Not found: 'dart:js'
export 'dart:js';
^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/js_wrapping-0.5.0/lib/adapter/js_list.dart:9:8: Error: Not found: 'dart:js'
import 'dart:js';
^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/js_wrapping-0.5.0/lib/adapter/js_map.dart:9:8: Error: Not found: 'dart:js'
import 'dart:js';
^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/google_maps_src.dart:203:45: Error: Type 'Node' not found.
with MapMixin<ControlPosition, MVCArray<Node>> {
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/google_maps_src.dart:207:12: Error: Type 'Node' not found.
MVCArray<Node> operator [](covariant ControlPosition key) {
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/google_maps_src.dart:214:51: Error: Type 'Node' not found.
void operator []=(ControlPosition key, MVCArray<Node> value) {
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/google_maps_src.dart:226:12: Error: Type 'Node' not found.
MVCArray<Node> remove(Object key) {
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/data/data_geometry_collection.dart:39:35: Error: Type 'JsObject' not found.
_DataGeometryCollection.created(JsObject o) : super.created(o);
^^^^^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/data/data_multi_line_string.dart:39:32: Error: Type 'JsObject' not found.
_DataMultiLineString.created(JsObject o) : super.created(o);
^^^^^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/data/data_multi_polygon.dart:43:29: Error: Type 'JsObject' not found.
_DataMultiPolygon.created(JsObject o) : super.created(o);
^^^^^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/data/data_polygon.dart:37:24: Error: Type 'JsObject' not found.
_DataPolygon.created(JsObject o) : super.created(o);
^^^^^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/map/map.dart:19:17: Error: Type 'Node' not found.
factory _GMap(Node mapDiv, [MapOptions opts]) => null;
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/map/map.dart:28:3: Error: Type 'Node' not found.
Node get div => _getDiv();
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/map/map.dart:29:3: Error: Type 'Node' not found.
Node _getDiv();
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/map_types/image_map_type.dart:23:3: Error: Type 'Node' not found.
Node Function(Point tileCoord, num zoom, Document ownerDocument) getTile;
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/map_types/image_map_type.dart:23:44: Error: Type 'Document' not found.
Node Function(Point tileCoord, num zoom, Document ownerDocument) getTile;
^^^^^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/map_types/image_map_type.dart:24:20: Error: Type 'Node' not found.
void releaseTile(Node tile);
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/map_types/map_type.dart:21:3: Error: Type 'Node' not found.
Node Function(Point tileCoord, num zoom, Document ownerDocument) getTile;
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/map_types/map_type.dart:21:44: Error: Type 'Document' not found.
Node Function(Point tileCoord, num zoom, Document ownerDocument) getTile;
^^^^^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/map_types/map_type.dart:22:20: Error: Type 'Node' not found.
void releaseTile(Node tile);
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/map_types/styled_map_type.dart:23:3: Error: Type 'Node' not found.
Node Function(Point tileCoord, num zoom, Document ownerDocument) getTile;
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/map_types/styled_map_type.dart:23:44: Error: Type 'Document' not found.
Node Function(Point tileCoord, num zoom, Document ownerDocument) getTile;
^^^^^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/map_types/styled_map_type.dart:24:20: Error: Type 'Node' not found.
void releaseTile(Node tile);
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/mvc/mvcarray.dart:29:21: Error: Type 'JsObject' not found.
_MVCArray.created(JsObject o, [Codec<E, dynamic> codec])
^^^^^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/overlays/map_panes.dart:21:3: Error: Type 'Node' not found.
Node floatPane;
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/overlays/map_panes.dart:22:3: Error: Type 'Node' not found.
Node mapPane;
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/overlays/map_panes.dart:23:3: Error: Type 'Node' not found.
Node markerLayer;
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/overlays/map_panes.dart:24:3: Error: Type 'Node' not found.
Node overlayLayer;
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/overlays/map_panes.dart:25:3: Error: Type 'Node' not found.
Node overlayMouseTarget;
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/save_to_google_maps/save_widget.dart:19:23: Error: Type 'Node' not found.
factory _SaveWidget(Node container, [SaveWidgetOptions opts]) => null;
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/services/directions_renderer.dart:25:3: Error: Type 'Node' not found.
Node get panel => _getPanel();
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/services/directions_renderer.dart:26:3: Error: Type 'Node' not found.
Node _getPanel();
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/services/directions_renderer.dart:35:13: Error: Type 'Node' not found.
set panel(Node panel) => _setPanel(panel);
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/services/directions_renderer.dart:36:18: Error: Type 'Node' not found.
void _setPanel(Node panel);
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/services/directions_renderer_options.dart:27:3: Error: Type 'Node' not found.
Node panel;
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/street_view/street_view_panorama.dart:19:31: Error: Type 'Node' not found.
factory _StreetViewPanorama(Node container,
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/core/street_view/street_view_panorama.dart:62:10: Error: Type 'JsObject' not found.
Stream<JsObject> get onCloseclick => getStream(this, 'closeclick');
^^^^^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/google_maps_src.g.dart:11:45: Error: Type 'Node' not found.
with MapMixin<ControlPosition, MVCArray<Node>> {
^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/google_maps_src.g.dart:13:20: Error: Type 'JsObject' not found.
Controls.created(JsObject o) : super.created(o);
^^^^^^^^
/F:/Flutter/cod/flutter_windows_v1.5.4-hotfix.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps-3.4.1/lib/src/google_maps_src.g.dart:16:12: Error: Type 'Node' not found.
MVCArray<Node> operator [](covariant ControlPosition key) {
^^^^