resolveOrThrow method

  1. @override
void resolveOrThrow(
  1. ReferenceResolver coder
)

Validates referenceURIs for this object and any objects it contains.

This method is automatically invoked by both KeyedArchive.unarchive and KeyedArchive.archive.

Implementation

@override
void resolveOrThrow(ReferenceResolver coder) {
  final referenceURI = this.referenceURI;
  if (referenceURI != null) {
    _objectReference = coder.resolve(referenceURI);
    if (_objectReference == null) {
      throw new ArgumentError(
          "Invalid document. Reference '#${referenceURI.path}' does not exist in document.");
    }
  }

  _map.forEach((key, val) {
    if (val is KeyedArchive) {
      val.resolveOrThrow(coder);
    } else if (val is ListArchive) {
      val.resolveOrThrow(coder);
    }
  });
}