getTripEventsById function

Future<List<PossibleIntervention>> getTripEventsById(
  1. String appTripId
)

Implementation

Future<List<PossibleIntervention>> getTripEventsById(
    String appTripId,
    ) async {
  try {
    String result = await platform.invokeMethod(
      'getTripEventsById',
      {"appTripId": appTripId},
    );
    if (kDebugMode) {
      print("Received Possible Interventions for App Trip ID: $result");
    }
    var decodedList = jsonDecode(result);
    if (kDebugMode) {
      print("decoded Possible Interventions for App Trip ID: $decodedList");
    }
    List<PossibleIntervention> list = List<PossibleIntervention>.from(
      decodedList.map((model) {
        PossibleIntervention possibleIntervention =
        PossibleIntervention.fromJson(model);

        return possibleIntervention;
      }),
    );

    if (kDebugMode) {
      print("-> Possible Interventions for App Trip ID List: $list");
    }

    return list;
  } on PlatformException catch (e, stacktrace) {
    if (kDebugMode) {
      print(e);
      print(stacktrace);
    }
    rethrow;
  } catch (e, stacktrace) {
    if (kDebugMode) {
      print(e);
      print(stacktrace);
    }
    throw PlatformException(code: "PLUGIN_ERROR", message: e.toString());
  }
}