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

插件详情v0.4.3

flutter_google_places_sdk

一个用于 Google Places SDK 的 Flutter 插件,它在每个平台上使用原生库

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2.5万
喜欢数
110
Pub 分数
140

安装插件

flutter pub add flutter_google_places_sdk

插件介绍

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

一个 Flutter 插件,集成 Android、iOS、Web、macOS、Windows 和 Linux 的原生 Google Places SDK。它使开发者能够使用各平台特定的原生库实现地点搜索、自动补全和地址选择功能,以获得最佳性能和一致性。该包简化了在 Flutter 应用中访问 Google 地理位置服务的过程,确保所有支持平台上的用户体验无缝衔接。

适合场景

  • 带自动完成的搜索
  • 表单中的地址选择
  • 基于地理位置的应用程序功能
  • 地图集成与地点数据
  • 用户位置发现
  • 旅行和配送应用功能增强

主要特点

  • 使用原生 Google Places SDK
  • 跨平台兼容性
  • 实时地点建议
  • 支持多个平台(Android、iOS、Web、macOS、Windows、Linux)
  • 轻量且高效
  • 与现有 Flutter 项目轻松集成

适合对象

  • 开发位置感知应用程序的开发者
  • 需要准确地址输入的应用程序
  • 旅行、外卖或拼车平台
  • 需要原生性能的项目
  • 希望在跨平台环境中保持一致的地点选择器行为的团队

使用建议

  • 需要配置 Google API 密钥
  • 依赖 Google Play 服务(Android)
  • 可能根据 Google Cloud 计费设置使用限制
  • Web 版本需要额外设置
  • iOS 需要正确的 Info.plist 配置
  • 初始加载时可能出现延迟

原始 README

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

flutter_google_places_sdk

pub package

Tests

A Flutter plugin for google places sdk that uses the native libraries on each platform. Check out Rational below to understand why you should use this plugin.

Usage

To use this plugin, add flutter_google_places_sdk as a dependency in your pubspec.yaml file.

Web Usage

When using the web support you also need to enable the Maps JavaScript API in google cloud:

https://developers.google.com/maps/documentation/javascript/get-api-key

Limits:

  • Location restriction is not supported. See google issue tracker for more info: https://issuetracker.google.com/issues/36219203

Rational

By now you probably found some other plugins, and wondering why this one was even created. Well, there's a good reason for that.

All other plugins will use http web requests rather than the native sdk.

Google allows you to limit the usage of your api key to your android application. However, that only works when you're using the native SDK.

So when using the http web requests method, you can't actually limit it, and if someone can get your API key (usually not a problem if it's in a mobile client), it can be used anywhere outside of it.

Example

import 'package:flutter/material.dart';
import 'package:flutter_google_places_sdk/flutter_google_places_sdk.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      body: Center(
        child: ElevatedButton(
          onPressed: () async {
            final places = FlutterGooglePlacesSdk('my-key');
            final predictions =
                await places.findAutocompletePredictions('Tel Aviv');
            print('Result: $predictions');
          },
          child: Text('Predict and print to console'),
        ),
      ),
    ),
  ));
}

Development & Contributing

This is a side project of mine, hence issues are usually dealt with on weekends.

PRs are more than welcome if anyone want to contribute. There are

Contribution Guidelines
  1. General code quality will adhere to new PRs, although nothing too strict. Specifics will discussed in each PRs.
  2. This is a multi-platform plugin, and each package is maintained independently. As part of it, each commit that changes the version is also tagged per platform. The result is that changes that require multiple packages will require multiple commits - and hence multiple PRs.

所属分类

依赖

依赖清单 7 项

源码仓库

使用此插件的项目

暂无相关数据。