flutter - Flutter中的Google Maps Place Picker包错误
问题描述
当我尝试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:错误:未找到:“dart:html”导入“dart:html”显示文档、元素、节点;
错误:未找到:“dart:js”导出“dart:js”显示allowInterop、allowInteropCaptureThis;
错误:未找到:“dart:js_util”导出“dart:js_util”;
错误:找不到类型“元素”。元素mapDiv,[^^^^^^^
错误:找不到类型“节点”。List<MVCArray> 获取控件 => ^^^^
错误:找不到类型“元素”。元素 _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_places
,google_maps_flutter
或任何其他包。
推荐阅读
- sql-server - 将 sql server 2000 连接到 Visual Studio 2015
- ethereum - 在循环中发送 .send 请求只会设置循环的最后一个值 i 次
- php - 卷曲 HTTP 发布问题
- android - Android、Xamarin、EditTexts:禁止用户删除第一个字母
- angular - ionic 2/3 检查标签文本是否被截断或不将其用作条件
- java - DGraph:在检索链接数据时获取 JSON 语法异常
- android - 引起:java.lang.ClassNotFoundException:在路径:DexPathList 上找不到类“com.crashlytics.android.beta.Beta”
- testing - 无法使用 Postman 中的变量对我的测试进行分支
- android - 如何在 CollapsingToolbarLayout 中将标题居中并显示后退图标
- android - 通过 Android 中的套接字更新位置