flutter_drivekit_driver_data 1.10.0 copy "flutter_drivekit_driver_data: ^1.10.0" to clipboard
flutter_drivekit_driver_data: ^1.10.0 copied to clipboard

This is the Flutter plugin for DriveQuant's DriveKit DriverData component.

DriveKit DriverData plugin #

Flutter interface for the DriveKit Driver Data

To learn more about DriveKit, please visit our DriveKit documentation

Installation #

To use this plugin, run this command in your project

flutter pub add flutter_drivekit_driver_data

Now, you can import 'package:flutter_drivekit_driver_data/flutter_drivekit_driver_data.dart' and use DriveKitDriverData in your Dart code.

Usage #

To use this plugin, you need to have an ApiKey from DriveQuant. If you don't have one, please contact us. Then, you need to install the flutter_drivekit_core plugin and follow the instructions to specify the ApiKey and the UserId.

Now, you can configure the DriveKit Core with the options you want, and start using the DriveKit Driver Data plugin.

Please refer to the DriveKit Driver Data documentation for more information about the features we provide.

You can also take a look at the flutter example for a basic usage of the DriveKit SDK, and the iOS example app or android example app for a complete demonstration.

Manual initialization #

If you have disabled the DriveKit auto-initialization:

  • On Android project, call initialize method of DriveKitDriverData class inside your MainApplication class.
// MainApplication.kt

// …
override fun onCreate() {
    super.onCreate()

    DriveKit.initialize()
    DriveKitTripAnalysis.initialize(…)
    DriveKitDriverData.initialize()
    (…)
}
  • On iOS project, call initialize method inside your AppDelegate.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    DriveKit.shared.initialize()
    DriveKitTripAnalysis.shared.initialize(appLaunchOptions: launchOptions)
    DriveKitDriverData.shared.initialize()
    (…)
}

API #

Method Return Type iOS Android
getTripsOrderByDateAsc() Future<GetTripsResponse?>
getTripsOrderByDateDesc() Future<GetTripsResponse?>
getTrip() Future<GetTripResponse>
getRoute() Future<GetRouteResponse>
deleteTrip() Future<bool>
updateDriverPassengerMode() Future<UpdateDriverPassengerModeStatus>

getTripsOrderByDateAsc #

getTripsOrderByDateDesc #

  Future<GetTripsResponse?> getTripsOrderByDateAsc(
        SynchronizationType synchronizationType = SynchronizationType.defaultSync,
    List<TransportationMode> transportationModes = const [
      TransportationMode.unknown,
      TransportationMode.car,
      TransportationMode.moto,
      TransportationMode.truck,
    ],
  );

or

  Future<GetTripsResponse?> getTripsOrderByDateDesc(
        SynchronizationType synchronizationType = SynchronizationType.defaultSync,
    List<TransportationMode> transportationModes = const [
      TransportationMode.unknown,
      TransportationMode.car,
      TransportationMode.moto,
      TransportationMode.truck,
    ],
  );
GetTripsResponse Type
status TripSyncStatus
trips [Trip]

To get driver's trips, you have to call the following method:

final tripSyncResult = await DriveKitDriverData.instance.getTripsOrderByDateAsc();

or

final tripSyncResult = await DriveKitDriverData.instance.getTripsOrderByDateDesc();

getTrip #

The itinId parameter is the unique identifier for a trip.

Future<GetTripResponse?> getTrip(String itinId);
GetTripResponse Type
status TripSyncStatus
trip Trip?

To get a specific trip, you have to call the following method:

final result = await DriveKitDriverData.instance.getTrip('TRIP_ID_HERE');

getRoute #

The itinId parameter is the unique identifier for a trip.

Future<GetRouteResponse?> getRoute(String itinId);
GetRouteResponse Type
status RouteSyncStatus
route Route?

To get a specific route, you have to call the following method:

final result = await DriveKitDriverData.instance.getRoute('TRIP_ID_HERE');

deleteTrip #

The itinId parameter is the unique identifier for a trip.

Future<bool> deleteTrip(String itinId);

To delete a trip, you have to call the following method:

final result = await DriveKitDriverData.instance.deleteTrip('TRIP_ID_HERE');

updateDriverPassengerMode #

When a trip is analyzed and the detected transportation mode is car, truck, or motorcycle, it is by default attributed to the driver. However, in some cases, the data may come from a passenger's smartphone.

In such cases, it is possible to indicate that the analyzed trip was recorded by an occupant of the vehicle who was not the driver. This section describes the method used to declare a trip as having been made as a passenger.

With this method, you can add a feature to your application that allows the user to declare that they were not the driver of the vehicle.

Remark: When a user declares that a trip was made as a passenger, it will not modify any scores related to the trip.

To declare a trip as a passenger with a comment, call the following code:

const itinId = 'TRIP_ID';
const comment = 'MY_COMMENT';
final result = await DriveKitDriverData.instance.updateDriverPassengerMode(itinId, DriverPassengerMode.passenger, comment);

The itinId parameter is the unique identifier for a trip. The user can add a comment of up to 120 characters with the comment parameter.