搜索插件、代码仓与 APP 分类

插件详情v2.1.1

google_places_flutter

适用于 Android 和 iOS 的自定义 Google 地点自动补全小部件。使用 https://pub.dev/packages/google_places_flutter

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
9.4万
喜欢数
100
Pub 分数
130

安装插件

flutter pub add google_places_flutter

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

适用于 Android、iOS、Web、macOS、Windows 和 Linux 上的 Flutter 应用的可自定义 Google 地点自动补全小部件。它允许用户通过 Google 地点 API 提供的实时建议搜索地点。该包简化了在表单或地图中集成地点选择的过程,为跨平台提供无缝体验。开发者可以自定义外观、处理地点选择并高效管理位置查询。非常适合需要地址输入、基于位置的服务或地理编码功能的应用程序。

适合场景

  • 表单中的地址输入
  • 基于位置的应用功能
  • 地理编码和地图集成
  • 旅行和配送应用
  • 用户配置文件位置设置
  • 事件地点选择

主要特点

  • 实时地点建议
  • 跨平台支持
  • 可自定义的 UI
  • 位置详情检索
  • 轻松的 API 集成
  • 支持多个平台

适合对象

  • 需要位置搜索的移动和网页应用
  • 使用 Google Places API 的开发者
  • 需要准确地址输入的应用程序
  • 位置感知应用
  • 构建跨平台解决方案的团队

使用建议

  • 需要 Google Places API 密钥
  • 可能产生使用费用
  • 依赖互联网连接
  • 自动完成下拉菜单的自定义选项有限
  • 建议中的潜在延迟
  • 需要对 API 失败情况进行适当的错误处理

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

google_places_flutter

Add dependency into pubspec.yml

dependencies:
  flutter:
    sdk: flutter
  google_places_flutter: <last-version>
  

Google AutoComplete TextField Widget code

    GooglePlaceAutoCompleteTextField(
        textEditingController: controller,
        googleAPIKey: "YOUR_GOOGLE_API_KEY",
        inputDecoration: InputDecoration()
        debounceTime: 800 // default 600 ms,
        countries: ["in","fr"],// optional by default null is set
        isLatLngRequired:true,// if you required coordinates from place detail
        getPlaceDetailWithLatLng: (Prediction prediction) {
         // this method will return latlng with place detail
        print("placeDetails" + prediction.lng.toString());
        }, // this callback is called when isLatLngRequired is true
        itemClick: (Prediction prediction) {
         controller.text=prediction.description;
          controller.selection = TextSelection.fromPosition(TextPosition(offset: prediction.description.length));
        }
        // if we want to make custom list item builder
        itemBuilder: (context, index, Prediction prediction) {
          return Container(
            padding: EdgeInsets.all(10),
            child: Row(
              children: [
                Icon(Icons.location_on),
                SizedBox(
                  width: 7,
                ),
                Expanded(child: Text("${prediction.description??""}"))
              ],
            ),
          );
        }
        // if you want to add seperator between list items
        seperatedBuilder: Divider(),
        // want to show close icon 
        isCrossBtnShown: true,
        // optional container padding
         containerHorizontalPadding: 10,
         // place type
        placeType: PlaceType.geocode,
        // keyboard type (defaults to TextInputType.streetAddress)
        keyboardType: TextInputType.text, // optional - defaults to streetAddress for better address input
         
         
        
        
    )
    

Customization Option

You can customize a text field input decoration and debounce time

Screenshorts

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

暂无相关数据。

所在榜单