Google Maps Place Picker 包在 Flutter 中出错

Google Maps Place Picker package Error in Flutter

当我在 flutter 中尝试 运行 使用 google_maps_place_picker 包的以下代码时,我收到了一大堆错误。

import 'package:flutter/material.dart';
// import 'package:google_maps/google_maps.dart';
import 'package:google_maps/google_maps.dart';
import 'package:google_maps_place_picker/google_maps_place_picker.dart'
    as place;
// import 'package:location/location.dart';

import '../components/location_helper.dart';
// import '../components/location_helper.dart';

class MapScreen extends StatelessWidget {
  final LatLng location1 = LatLng(37.657, -122.776);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('Map Screen'),
        ),
        body: Center(
          child: place.PlacePicker(
              apiKey: GOOGLE_API,
              useCurrentLocation: true,
              onPlacePicked: (result) {
                print(result.addressComponents);
                Navigator.of(context).pop();
              }),
        ));
  }
}

错误

5:8: Error: Not found: 'dart:html' import 'dart:html' show Document, Element, Node;

Error: Not found: 'dart:js' export 'dart:js' show allowInterop, allowInteropCaptureThis;

Error: Not found: 'dart:js_util' export 'dart:js_util';

Error: Type 'Element' not found. Element mapDiv, [ ^^^^^^^

Error: Type 'Node' not found. List<MVCArray> get controls => ^^^^

Error: Type 'Element' not found. Element _getDiv() => callMethod(this, 'getDiv', []); ^^^^^^^

这些只是我提出的一些错误。还有很多这样的。

我已经在我的 pubspec.yaml 文件中添加了这些依赖项。

  google_maps_flutter: ^1.2.0
  geodesy: ^0.3.2
  confirm_dialog: ^0.1.1
  geocoding: ^1.0.5
  geocoder: ^0.2.1
  google_maps_place_picker: ^1.0.1
  tuple: ^1.0.3
  js: ^0.6.2
  html: ^0.14.0+4

您正在使用 import 'package:google_maps/google_maps.dart';

google_maps 包 仅支持 web。对于移动支持,应尝试 flutter_google_placesgoogle_maps_flutter 或任何其他软件包。