一個 Flutter 套件,提供基於 HTTP 的實作,用於將 Google Places 功能整合至應用程式中。它支援在 Android、iOS、Web、macOS、Windows 與 Linux 等多個平台上的位置、地點與地址搜尋功能。設計為其他平台特定實作的基礎層,透過 HTTP 請求與 Google Places API 通訊,提供彈性與相容性,無需原生程式碼。適合尋求輕量級、跨平台地點查詢與自動補全功能的開發者。
適用情境
在表單中使用地址自動補全
地址搜尋與選擇
地理位置數據獲取
跨平台位置服務
與基於地圖的應用程式整合
主要特色
基於HTTP的API通訊
多平台支援
輕量且模組化的設計
與原生外掛相容
透過 HTTP 請求實現簡單整合
適合對象
開發跨平台應用的開發者
不需要原生 SDK 的應用需要地點搜尋
使用自定平台實作的專案
更傾向於使用 HTTP 而非原生依賴的團隊
使用建議
需要互聯網連接
依賴 Google Places API 金鑰
僅限 HTTP 請求功能
不是完整的原生外掛
可能需要為 API 回應新增額外的錯誤處理
原始 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.