BoxAnswer.fromJson constructor

BoxAnswer.fromJson(
  1. Map<String, Object?> json
)

Implementation

factory BoxAnswer.fromJson(Map<String, Object?> json) {
  final box = readObject(json, 'box');
  try {
    return BoxAnswer(
      top: readDouble(box, 'top'),
      bottom: readDouble(box, 'bottom'),
      left: readDouble(box, 'left'),
      right: readDouble(box, 'right'),
      confidence: readDouble(json, 'confidence'),
    );
  } on ResponseValidationException catch (e) {
    // Only the edges live under `box`; confidence sits beside it.
    if (e.fieldPath == 'confidence') {
      rethrow;
    }
    throw nestUnder(e, 'box');
  }
}