FLUTTER ECOSYSTEM

LJaraCastillo/flutter_sensor_compass

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

flutter_sensor_compass 專案封面
Stars
1
Forks
1
最近推送(UTC)
2019年11月26日
專案狀態
未封存
Luis Andrés Jara Castillo GitHub avatar
GITHUB User

Luis Andrés Jara Castillo ↗

I'm a software engineer graduated from University of La Frontera.

Temuco, Chile
語言DartRubyKotlinSwiftObjective-C

此儲存庫發佈的套件

使用的依賴

依賴清單 3 項

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

展開 / 收合專案 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();