getDrivingBehaviourScore method
Future<DrivingBehaviourScore?>
getDrivingBehaviourScore(
- DateTime startTime,
- DateTime endTime,
- KruzrPerioicType kruzrPerioicType
Retrieves detailed driving behavior scores broken down by category.
Provides granular analysis of driving behavior including scores for specific categories like acceleration, braking, cornering, speeding, etc.
Parameters:
startTime: Beginning of the time rangeendTime: End of the time rangekruzrPerioicType: Aggregation period (daily, weekly, monthly)
Returns:
DrivingBehaviourScore?: Detailed behavior scores by category, ornullif not available
Usage:
try {
final behaviorScore = await communicator.getDrivingBehaviourScore(
DateTime.now().subtract(Duration(days: 7)),
DateTime.now(),
KruzrPerioicType.daily,
);
if (behaviorScore != null) {
print('Acceleration score: ${behaviorScore.accelerationScore}');
print('Braking score: ${behaviorScore.brakingScore}');
print('Cornering score: ${behaviorScore.corneringScore}');
}
} catch (e) {
print('Failed to get behavior score: $e');
}
Throws:
Future.error("Unable to get aggregated driving behaviour score"): When retrieval fails
Implementation
Future<DrivingBehaviourScore?> getDrivingBehaviourScore(
DateTime startTime,
DateTime endTime,
KruzrPerioicType kruzrPerioicType,
) async {
try {
return await kruzr_comm.getDrivingBehaviourScore(
startTime,
endTime,
kruzrPerioicType,
);
} on PlatformException catch (e) {
if (kDebugMode) {
print(e);
print("PlatformException in getDrivingBehaviourScore");
}
return Future.error({"code": e.code, "message": e.message, "details": e.details});
} on Exception catch (e) {
if (kDebugMode) {
print(e);
print("Exception in getDrivingBehaviourScore");
}
return Future.error(PlatformException(code: "PLUGIN_ERROR", message: e.toString()));
}
}