simple_flutter_compass

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

simple flutter compass

simple_flutter_compass #
Simple Flutter Compass for accessing device's current heading (like a compass) using its magnetometer.
How to use : #
- Import the plugin
- create an instance of SimpleFlutterCompass()
- create a listener and set it to the new instance
- call check() to see if device supports or has the hardware needed
- call listen() to start listening for heading changes
- call stopListen() when you're done
copied to clipboard
Getting Started #
Import Plugin
import 'package:simple_flutter_compass/simple_flutter_compass.dart';
copied to clipboard
Create Instance
SimpleFlutterCompass _simpleFlutterCompass = SimpleFlutterCompass();
copied to clipboard
Check if hardware exists and set a listener
_simpleFlutterCompass.check().then((result) {
if (result) {
_simpleFlutterCompass.setListener(_streamListener);
} else {
print("Hardware not available");
}
});

void _streamListener(double currentHeading) {
setState(() {
//we set the new heading value to our _compas variable to display on screen
_compas = currentHeading;
});
}
copied to clipboard
Start listening
_simpleFlutterCompass.listen();
copied to clipboard
Stop listening
_simpleFlutterCompass.stopListen();
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.

Related Products

More From This Creator