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

套件詳情v1.0.1

compassx

Flutter 指南針外掛程式,提供真實航向、準確度和校準需求。

AndroidiOS
近 30 天下載
3010
喜歡數
20
Pub 分數
150

安裝套件

flutter pub add compassx

套件介紹

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

CompassX 是一個 Flutter 插件,可提供對裝置指南針資料的存取,包含真實航向、磁性準確度與校準狀態。它支援 Android 與 iOS 平台,透過裝置感應器即時提供方向資訊。此插件非常適合需要精確方向輸入的導航、地圖與擴增實境應用。僅需透過 `flutter pub add compassx` 簡單設定,開發者即可將可靠的指南針功能整合至其應用中。原始碼公開於 GitHub,以確保透明度與客製化。

適用情境

  • 導航應用
  • 增強現實體驗
  • 戶外活動追蹤
  • 基於地圖的應用程式
  • 方向性UI元素

主要特色

  • 真航向支援
  • 磁性精度報告
  • 即時感測器更新
  • 校準狀態監控
  • 跨平台相容性

適合對象

  • 開發導航工具的開發者
  • 需要方向意識的應用程式
  • AR 和基於位置的服務
  • 需要傳感器整合的行動應用程式

使用建議

  • 需要具備磁力計的裝置
  • 準確性取決於環境
  • 可能需要使用者校準
  • 某些設備上的背景操作受到限制
  • iOS 需要隱私權限

原始 README

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

CompassX

Logo

Provides reliable compass data and extensive documentation.

Usage

StreamBuilder<CompassXEvent>(
  stream: CompassX.events,
  builder: (context, snapshot) {
    if (!snapshot.hasData) return const Text('No data');
    final compass = snapshot.data!;
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        Text('Heading: ${compass.heading}'),
        Text('Accuracy: ${compass.accuracy}'),
        Text('Should calibrate: ${compass.shouldCalibrate}'),
        Transform.rotate(
          angle: compass.heading * math.pi / 180,
          child: Icon(
            Icons.arrow_upward_rounded,
            size: MediaQuery.of(context).size.width - 80,
          ),
        ),
      ],
    );
  },
),
  • heading: The heading relative to true north in degree.
  • accuracy: The accuracy of the sensor data.
  • shouldCalibrate: Whether the sensor should be calibrated or not.

Install

$ flutter pub add compassx

Check the minimum supported version of your project and update as necessary.

  • iOS: 12
  • Android: 21

Request permission to get true heading in Android. Not required on iOS.

$ flutter pub add permission_handler

Specify the permissions one or both of the following in AndroidManifest.xml. It can be copied from example.

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  • ACCESS_COARSE_LOCATION: Used when normal accuracy is required.
  • ACCESS_FINE_LOCATION: Used when the highest quality accuracy is required.

Add code to request permissions.

if (Platform.isAndroid) await Permission.location.request();

CompassX heading currently supports only portrait mode. It is recommended to fix the orientation of the device.

SystemChrome.setPreferredOrientations([
        DeviceOrientation.portraitUp,
        DeviceOrientation.portraitDown,
      ]);

Testing

It is recommended to use a real device. iOS simulators cannot use the heading sensor (compass). See Testing CompassX for details.

Documentation

If you are going to use this plugin in your product apps, I strongly suggest you read full documentation carefully.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。