搜尋套件、儲存庫與 APP 分類

location 封面
套件詳情v10.2.0

location

跨平台插件,可輕鬆即時存取裝置位置。

AndroidiOSWebmacOS
近 30 天下載
22.6萬
喜歡數
3210
Pub 分數
150

安裝套件

flutter pub add location

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

location 套件為 Android、iOS、Web 與 macOS 提供跨平台的即時裝置位置存取解決方案。它透過跨平台一致的 API 簡化地理定位任務,讓開發者能輕鬆取得目前位置、監控位置變更並順暢處理權限。此套件設計以易用為導向,抽象出平台特定的複雜性,同時維持可靠性與效能。非常適合需要位置相關服務的應用程式,例如地圖、追蹤或近距離功能。

適用情境

  • 即時位置追蹤
  • 地理圍欄整合
  • 基於地圖的應用程式
  • 用戶位置檢索
  • 位置感知通知
  • 旅行和導航應用

主要特色

  • 跨平台相容性
  • 即時位置更新
  • 權限處理
  • 簡單API介面
  • 支援所有主要平台
  • 後台位置存取

適合對象

  • 行動應用開發者
  • 基於位置的服務應用
  • 追蹤和映射工具
  • 網頁和桌面位置應用
  • 需要精確設備定位的應用程式

使用建議

  • 需要正確的權限配置
  • 背景位置可能會影響電池壽命
  • Web 支援僅限瀏覽器地理定位
  • iOS 要求在 info.plist 中包含隱私說明
  • Android 需要在清單檔案中具有位置權限
  • 準確性取決於設備硬體

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

📍 Flutter Location

The easiest way to get a device's location in real-time — on every platform Flutter runs.

One simple API for GPS coordinates, live location streams and background tracking on Android, iOS, macOS, Web, Windows and Linux.

pub version pub likes pub points codecov license

📖 Documentation  ·  🌐 Live web demo  ·  📦 pub.dev  ·  💬 Feedback


✨ Why Location?

  • 🌍 Truly cross-platform — the same code runs on all six Flutter targets, no per-platform branching.
  • ⚡ One-line to a fix — await location.getLocation() and you're done.
  • 🔴 Real-time streams — subscribe to onLocationChanged for continuous updates.
  • 🌙 Background tracking — keep receiving locations while your app is backgrounded on Android & iOS.
  • 🎛️ Tunable — pick accuracy, update interval and distance filter to balance precision vs. battery.
  • 🔔 Customizable notification — full control over the Android foreground-service notification.
  • 📊 Rich data — latitude, longitude, altitude, speed, heading, accuracy, mock detection and more.
  • 🛡️ Battle-tested — one of the most-used location plugins in the Flutter ecosystem, maintained since 2017.

📱 Platform support

Feature Android iOS macOS Web Windows Linux
One-time location ✅ ✅ ✅ ✅ ✅ ✅
Location stream ✅ ✅ ✅ ✅ ✅ ✅
Background updates ✅ ✅ — — — —
Permission handling ✅ ✅ ✅ ✅ ✅ ✅

Windows uses Windows.Devices.Geolocation; Linux talks to GeoClue2 over D-Bus. Both require the system location service to be enabled.

Watch the demo on YouTube

🚀 Quick start

Add the package:

dependencies:
  location: ^10.0.0

Get a location:

import 'package:location/location.dart';

final location = Location();

// Make sure the service is on and permission is granted.
if (!await location.serviceEnabled() && !await location.requestService()) return;
if (await location.requestPermission() != PermissionStatus.granted) return;

// One-time fix…
final current = await location.getLocation();
print('${current.latitude}, ${current.longitude}');

// …or a live stream.
location.onLocationChanged.listen((loc) {
  print('Moved to ${loc.latitude}, ${loc.longitude}');
});

That's it. Platform setup (permissions, background mode, sandbox entitlements) and the full API are covered in the package README and the documentation website.

📦 Packages in this repository

Package Description pub.dev
location The plugin you use in your app. pub
location_platform_interface Shared platform interface. pub
location_web Web implementation. pub

🤝 Contributing

Issues and pull requests are very welcome — this plugin is community-maintained and we're always looking for help. Browse the open issues to get started, or open a new one to report a bug or request a feature.

👥 Maintainers

📄 License

Released under the MIT License. © 2017 Guillaume Bernos.

所屬分類

依賴

依賴清單 2 項

  • location_platform_interface^7.0.0
  • location_web^7.0.0

原始碼儲存庫

使用此套件的專案

所在榜單