一個 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
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.
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';
voidmain() {
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
General code quality will adhere to new PRs, although nothing too strict. Specifics will discussed in each PRs.
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.