CodeAsset.fromEncoded constructor

CodeAsset.fromEncoded(
  1. EncodedAsset asset
)

Implementation

factory CodeAsset.fromEncoded(EncodedAsset asset) {
  assert(asset.type == CodeAsset.type);
  final jsonMap = asset.encoding;

  final linkMode =
      LinkMode.fromJson(as<Map<String, Object?>>(jsonMap[_linkModeKey]));
  final fileString = jsonMap.optionalString(_fileKey);
  final Uri? file;
  if (fileString != null) {
    file = Uri.file(fileString);
  } else {
    file = null;
  }
  final Architecture? architecture;
  final os = OS.fromString(jsonMap.string(_osKey));
  final architectureString = jsonMap.optionalString(_architectureKey);
  if (architectureString != null) {
    architecture = Architecture.fromString(architectureString);
  } else {
    architecture = null;
  }

  return CodeAsset._(
    id: jsonMap.string(_idKey),
    os: os,
    architecture: architecture,
    linkMode: linkMode,
    file: file,
  );
}