fromNative static method
Implementation
static List<MoveServiceError> fromNative(errors) {
List<MoveServiceError> moveWarnings = [];
for (var warning in errors) {
String service = warning["service"];
List reasons = warning["reasons"];
MoveDetectionService? targetService =
MoveDetectionService.values.firstWhereOrNull(
(element) => element.name.toLowerCase() == service.toLowerCase(),
);
if (targetService != null) {
List<MoveError> targetReasons = reasons
.map((e) {
var entry = MoveError.values.firstWhereOrNull(
(element) => element.name.toLowerCase() == e.toLowerCase(),
);
if (entry == null) {
print("error $e unknown");
}
return entry;
})
.whereNotNullable()
.toList();
moveWarnings.add(
MoveServiceError(service: targetService, reasons: targetReasons),
);
}
}
return moveWarnings;
}