flutter_compass
0.8.1, released 2 years ago by hemanthraj.in
A Flutter compass plugin providing a heading stream from 0 to 360 degrees.
What it does
Provides a compass heading stream ranging from 0 to 360 degrees where 0 represents north. It uses native sensors on Android and iOS to calculate orientation and heading. It also accounts for device orientation and handles sensor fallback mechanisms.
AI-written summary of version 0.8.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to build a compass feature in your app
- You need real-time device heading updates via a stream
Skip it when
- Targeting platforms where sensors are completely unavailable or unsupported (like standard web which returns an empty stream)
Strengths
- Simple and straightforward API
- Accounts for device orientation matrix on both iOS and Android for stable readings
- Provides accuracy and camera heading data through CompassEvent
Weaknesses
- Requires manual native configuration and permissions on Android and iOS
- Web platform support is minimal and always returns an empty stream
Setup
- Kind
- Plugin (native code)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 0
Requires adding location permissions and usage descriptions to AndroidManifest.xml and Info.plist.
StreamBuilder<CompassEvent>(
stream: FlutterCompass.events,
builder: (context, snapshot) {
if (snapshot.hasError) {
return Text('Error reading heading: ${snapshot.error}');
}
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
}
double? direction = snapshot.data?.heading;
if (direction == null) {
return const Text('Device does not have sensors');
}
return Text('Heading: $direction');
},
)Alternatives
Packages that do the same job and could replace flutter_compass.
- sensors_plus
If you need broader device motion and orientation sensors like accelerometer, gyroscope, and magnetometer instead of a pre-calculated compass heading.
96Compare