getPossibleInterventionsForAppTripId function

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

Implementation

Future<List<PossibleIntervention>> getPossibleInterventionsForAppTripId(
  String appTripId,
) async {
  try {
    String result = await platform.invokeMethod(
      'getPossibleInterventionsForAppTripId',
      {"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;
  } catch (e, stacktrace) {
    if (kDebugMode) {
      print(e);
      print(stacktrace);
    }

    return [];
  }
}