flutter_sensor_compass 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

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.

    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.

<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.


Changelog #

0.1.1 #

  • Updated Android dependencies

0.1.0 #

  • Compass stream to receive compass updates.
  • Function to test if the compass is usable in the device (accelerometer and magnetic field sensor is needed).
  • Added delay control for updates.


flutter_sensor_compass_example #

Demonstrates how to use the flutter_sensor_compass plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_sensor_compass: ^0.1.1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_sensor_compass/flutter_sensor_compass.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.8


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_sensors ^0.1.2 0.1.5
vector_math ^2.0.8 2.0.8
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6