fromNative static method

List<MoveServiceWarning> fromNative(
  1. dynamic warnings
)

Implementation

static List<MoveServiceWarning> fromNative(warnings) {
  List<MoveServiceWarning> moveWarnings = [];
  for (var warning in warnings) {
    String service = warning["service"];
    List reasons = warning["reasons"];

    MoveDetectionService? targetService = MoveDetectionService.values
        .firstWhereOrNull(
            (element) => element.name.toLowerCase() == service.toLowerCase());

    List<MoveWarning> targetReasons = reasons
        .map((e) => MoveWarning.values.firstWhere(
            (element) => element.name.toLowerCase() == e.toLowerCase()))
        .toList();

    moveWarnings.add(MoveServiceWarning(
      service: targetService,
      reasons: targetReasons,
    ));
  }
  return moveWarnings;
}