NavigationRegion.fromJson constructor

NavigationRegion.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json, {
  4. ClientUriConverter? clientUriConverter,
})

Implementation

factory NavigationRegion.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is Map) {
    int offset;
    if (json.containsKey('offset')) {
      offset = jsonDecoder.decodeInt('$jsonPath.offset', json['offset']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'offset');
    }
    int length;
    if (json.containsKey('length')) {
      length = jsonDecoder.decodeInt('$jsonPath.length', json['length']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'length');
    }
    List<int> targets;
    if (json.containsKey('targets')) {
      targets = jsonDecoder.decodeList(
        '$jsonPath.targets',
        json['targets'],
        jsonDecoder.decodeInt,
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'targets');
    }
    return NavigationRegion(offset, length, targets);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'NavigationRegion', json);
  }
}