搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。

所在榜單