CompassController class
Controller for managing map compass functionality and bearing state.
This controller handles:
- Map bearing updates
- North alignment functionality
- Compass state management
The controller requires a map instance to function properly and manages the compass bearing through CompassModel.
Usage example:
final controller = CompassController(
map: mapInstance,
);
// Access current bearing
print(controller.state.value.bearing);
// Rotate map to north
controller.rotateToNorth();
// Listen to bearing changes
controller.state.addListener(() {
final bearing = controller.state.value.bearing;
print('Map rotated to: $bearing degrees');
});
The controller maintains the compass state through CompassModel which contains the current map bearing in degrees. State changes can be observed through the state ValueNotifier.
Remember to dispose of the controller when it's no longer needed:
controller.dispose();
Constructors
- CompassController({required Map map})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- map → Map
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
state
→ ValueNotifier<
CompassModel> -
no setter
Methods
-
dispose(
) → void -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
rotateToNorth(
) → void -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited