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) {
    throw jsonDecoder.mismatch(jsonPath, "'NavigationRegion'", json);
  }
  int offset;
  if (json case {'offset': var encodedOffset}) {
    offset = jsonDecoder.decodeInt('$jsonPath.offset', encodedOffset);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'offset'", json);
  }
  int length;
  if (json case {'length': var encodedLength}) {
    length = jsonDecoder.decodeInt('$jsonPath.length', encodedLength);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'length'", json);
  }
  List<int> targets;
  if (json case {'targets': var encodedTargets}) {
    targets = jsonDecoder.decodeList(
      '$jsonPath.targets',
      encodedTargets,
      jsonDecoder.decodeInt,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'targets'", json);
  }
  return NavigationRegion(offset, length, targets);
}