Search packages, repositories and app categories

Package detailsv0.1.1

flutter_sensor_compass

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

30-day downloads
27
Likes
3
Pub points
40

Install package

flutter pub add flutter_sensor_compass

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The flutter_sensor_compass package provides a simple way to access the device's compass sensor, delivering real-time orientation data in degrees relative to magnetic north. It enables apps to detect the device's direction, making it ideal for navigation, augmented reality, and location-based services. The plugin works by leveraging the device's built-in magnetometer and is designed for seamless integration into Flutter applications. It supports background updates and offers accurate readings with minimal configuration. Developers can easily subscribe to orientation changes and react accordingly.

Use cases

  • Navigation apps
  • Augmented reality experiences
  • Location-based games
  • Outdoor activity tracking
  • Map orientation

Key features

  • Real-time compass data
  • Magnetic north orientation
  • Background sensor updates
  • Simple API integration
  • Cross-platform support

Suitable for

  • Developers building navigation tools
  • Apps requiring device direction sensing
  • AR and VR applications
  • Fitness and outdoor tracking apps

Considerations

  • Requires device with magnetometer
  • May need calibration for accuracy
  • Limited on devices without sensors
  • Battery usage due to continuous polling
  • Accuracy affected by nearby magnetic interference

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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();

Categories

Dependencies

Dependency list 2 items

Source repository

Projects using this package

No data available yet.