DashboardController class
Controller for managing the dashboard widget's state and functionality during navigation.
This controller handles:
- Real-time navigation updates (distance, duration)
- Sound settings management
- Route visualization
- Navigation state formatting
The controller requires both navigationManager and map instances to function properly.
Usage with NavigationLayoutWidget: This controller is created automatically by the widget and provided through the builder function in NavigationLayoutWidget's constructor:
NavigationLayoutWidget(
dashboardWidgetBuilder: (controller, callback) => DashboardWidget(
controller: controller,
onHeaderChangeSize: callback,
onFinishClicked: () => navigationManager.stop(),
),
),
This architecture allows the controller to be used by custom widgets derived from DashboardWidget.
Example of controller usage:
// Access current state
print(controller.distance);
print(controller.duration);
// Format values
final formattedDistance = controller.formatDistance(localizations);
final formattedDuration = controller.formatDuration(localizations);
// Control navigation
controller.toggleSounds();
controller.showRoute();
controller.stopNavigation();
Remember to dispose of the controller when it's no longer needed:
controller.dispose();
Controller also exposes sdk.Map and sdk.NavigationManager to widget so they can be used for some non-standart logic inside widget.
Constructors
- DashboardController({required Map map})
Properties
- distance → int
-
The current distance remaining in meters.
no setter
- duration → int
-
The current duration remaining in seconds.
no setter
- estimatedArrivalTime → DateTime
-
The estimated time of arrival based on current duration.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- map → Map
-
final
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- soundsEnabled → bool
-
Whether navigation voice instructions are enabled.
no setter
-
state
→ ValueNotifier<
DashboardModel> -
The current state of the dashboard as a ValueNotifier.
Contains distance, duration, and sound settings.
no setter
Methods
-
dispose(
) → void -
formatArrivalTime(
DateFormat formatter) → String - Formats the estimatedArrivalTime using the provided date formatter.
-
formatDistance(
DgisLocalizations localizations) → FormattedMeasure -
Formats the current distance according to the provided localizations.
Returns a
FormattedMeasure
containing the value and unit. -
formatDuration(
DgisLocalizations localizations) → FormattedMeasure -
Formats the current duration according to the provided localizations.
Returns a
FormattedMeasure
containing the value and unit. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
showRoute(
) → Future< void> - Shows the remaining route on the map. Calculates and moves the camera to fit the remaining route geometry.
- Stops the current navigation session.
-
toggleSounds(
) → void - Toggles the sound state for navigation instructions. Updates the soundsEnabled state and state accordingly.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited