macOS 專用的 Flutter 插件實作,適用於 Google Places SDK,讓開發者能將 Google Places 功能整合至 macOS 應用程式中。此套件允許使用者在原生 macOS 應用中直接搜尋地點、取得地點詳細資料,並存取自動補完建議。該套件透過平台通訊渠道使用 Google 的 Places API,確保與底層 Google 服務的無縫互動。專為針對 macOS 的開發者設計,支援基於位置的搜尋與地點預測功能,設定簡單。
適用情境
在 macOS 桌面應用中整合位置搜尋
實作地址自動補完
取得位置的詳細資訊
在 macOS 上建構旅行或物流應用
在生產力工具中啟用位置發現
主要特色
原生 macOS 集成
位置自動補全與搜尋
支援取得地點詳細資訊
平台通道通訊
透過 Flutter pub 實現簡易設定
適合對象
使用位置功能開發 macOS 應用的開發者
需要地址輸入並提供建議的應用程式
使用 Google Places API 的桌面應用程式
針對跨平台 macOS 支援的 Flutter 團隊
需要在 Apple 桌面設備上提供可靠位置資料的專案
使用建議
需要 Google Cloud Platform API 憑證
僅限 macOS 平台
依賴互聯網連接
若跨平台使用,可能需要針對 iOS/Android 進行額外設定
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.