Runtime.deserialize constructor

Runtime.deserialize(
  1. Object serialized
)

Converts a JSON-safe representation generated by serialize back into a Runtime.

Implementation

factory Runtime.deserialize(Object serialized) {
  if (serialized is String) {
    return builtIn
        .firstWhere((platform) => platform.identifier == serialized);
  }

  var map = serialized as Map;
  var parent = map['parent'];
  if (parent != null) {
    // Note that the returned platform's [parent] won't necessarily be `==` to
    // a separately-deserialized parent platform. This should be fine, though,
    // since we only deserialize platforms in the remote execution context
    // where they're only used to evaluate platform selectors.
    return Runtime._child(map['name'] as String, map['identifier'] as String,
        Runtime.deserialize(parent));
  }

  return Runtime(map['name'] as String, map['identifier'] as String,
      isDartVM: map['isDartVM'] as bool,
      isBrowser: map['isBrowser'] as bool,
      isJS: map['isJS'] as bool,
      isBlink: map['isBlink'] as bool,
      isHeadless: map['isHeadless'] as bool);
}