TripService class abstract

Service interface for trip tracking operations.

Trips represent distinct journeys with start/end points, routes, and associated metadata. Use this for delivery tracking, commute logging, or any journey-based feature.

Example:

// Start a trip
await Locus.trips.start(TripConfig(
  identifier: 'delivery-123',
  metadata: {'orderId': 'ABC123'},
));

// Listen to trip events
Locus.trips.events.listen((event) {
  switch (event.type) {
    case TripEventType.started:
      print('Trip started');
      break;
    case TripEventType.updated:
      print('Trip updated: ${event.distance}m');
      break;
    case TripEventType.completed:
      print('Trip completed: ${event.summary}');
      break;
  }
});

// Stop the trip
final summary = Locus.trips.stop();
print('Total distance: ${summary?.totalDistance}m');
Implementers

Constructors

TripService()

Properties

events Stream<TripEvent>
Stream of trip events.
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getState() TripState?
Gets the current trip state.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onEvent(void callback(TripEvent event), {Function? onError}) StreamSubscription<TripEvent>
Subscribes to trip events.
start(TripConfig config) Future<void>
Starts a new trip with the given configuration.
stop() TripSummary?
Stops the current trip and returns a summary.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited