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

套件詳情v0.1.1

flutter_sensor_compass

一個用於取得裝置相對於磁北方向的方位角(以度為單位)的外掛程式。

近 30 天下載
32
喜歡數
3
Pub 分數
40

安裝套件

flutter pub add flutter_sensor_compass

套件介紹

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

flutter_sensor_compass 套件提供了一種簡單的方式來存取裝置的指南針感測器,提供相對於磁北的即時方向資料(以度為單位)。它讓應用程式能夠偵測裝置的方向,非常適合用於導航、擴增實境與基於位置的服務。此外掛程式透過利用裝置內建的磁力計運作,並設計為能順暢整合至 Flutter 應用程式中。支援背景更新,並在最少設定的情況下提供精確讀數。開發者可輕鬆訂閱方向變更並做出相應反應。

適用情境

  • 導航應用
  • 增強現實體驗
  • 基於位置的遊戲
  • 戶外活動追蹤
  • 地圖方向

主要特色

  • 即時指南針數據
  • 磁北方向
  • 背景傳感器更新
  • 簡單 API 結合
  • 跨平台支援

適合對象

  • 開發導航工具的開發者
  • 需要設備方向感應的應用程式
  • AR和VR應用
  • 健身和戶外追蹤應用

使用建議

  • 需要具備磁力計的裝置
  • 可能需要校準以確保準確性
  • 設備無感應器時受限
  • 由於持續輪詢導致的電池使用
  • 準確性受附近磁干擾影響

原始 README

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

flutter_sensor_compass

A plugin to get the orientation of the device (in degrees) relative to the magnetic north.

Installation

First add the plugin in your project. Copy the following line below dependencies in your pubspec.yaml file.

dependencies:
     ...
    flutter_sensor_compass: ^0.1.1

Then you need to import the dependency.

import 'package:flutter_sensor_compass/flutter_sensor_compass.dart';
iOS only

You need to add the following key-value pair into your Info.plist file inside the ios/Runner folder in your project.

<key>NSMotionUsageDescription</key>
<string>A reason to get the permission</string>

How to use

You can check if the device is capable of using the compass.

bool isAvailable = await Compass().isCompassAvailable();

Then you can register a new listener for the compass updates.

_compassSubscription =
        Compass().compassUpdates(interval: Duration(milliseconds: 200)).listen((value) {
      setState(() {
        _degrees = value;
      });
    });

Remember to cancel your StreamSubscriptions after you are done with the compass updates.

_compassSubscription.cancel();

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。