getValue method

Future<Object> getValue ({dynamic onUnknownValue(dynamic value) })

Returns a local Dart copy of the remote Dart object.

This creates a copy of all copyable objects with corresponding VMInstanceRef subclasses. If an uncopyable or unknown instance is encountered, an UnsupportedError is thrown. If an instance has exired, a VMSentinelException is thrown.

If onUnknownValue is provided, it's called with any uncopyable instances or sentinels that are encountered. Its return value is used as the value of that instance or sentinel. It may return a Future, in which case the completion value of the future is used.

This is safe to use with object graphs that contain loops. Within the scope of a call to getValue, including within calls to onUnknownValue, return values are cached, so multiple calls to getValue for the same instance will return identical Dart objects.

Implementation

Future<Object> getValue({onUnknownValue(value)}) async {
  if (Zone.current[#_cache] != null) return _getValue(onUnknownValue);
  return runZoned(() => _getValue(onUnknownValue), zoneValues: {#_cache: {}});
}