fetchTripInsights function

Future<TripInsights?> fetchTripInsights(
  1. String appTripId
)

Implementation

Future<TripInsights?> fetchTripInsights(String appTripId) async {
  try {
    String result = await platform.invokeMethod(
      'fetchTripInsights',
      {"appTripId": appTripId},
    );

    if (kDebugMode) {
      print("Received Trip Insights: $result");
    }

    final decoded = jsonDecode(result);

    return TripInsights.fromJson(decoded);
  } catch (e, stacktrace) {
    if (kDebugMode) {
      print("Error in fetchTripInsights");
      print(e);
      print(stacktrace);
    }
    return null;
  }
}