ReleasePackerFile.fromJson constructor

ReleasePackerFile.fromJson(
  1. Object json
)

Implementation

factory ReleasePackerFile.fromJson(Object json) {
  if (json is String) {
    return ReleasePackerFile(json, json);
  } else if (json is Map) {
    var platform = json['platform'];
    var dartCompileExe = json['dart_compile_exe'] as String?;
    var dartCompileKernel = json['dart_compile_kernel'] as String?;
    var windowsGUI = json['windows_gui'];

    var entry = json.entries
        .where((e) =>
            e.key != 'platform' &&
            e.key != 'dart_compile_exe' &&
            e.key != 'dart_compile_kernel' &&
            e.key != 'windows_gui')
        .first;

    if (windowsGUI is bool && windowsGUI) {
      windowsGUI = dartCompileExe ?? entry.key;
    }

    return ReleasePackerFile(entry.key, entry.value,
        platform: platform,
        dartCompileExe: dartCompileExe,
        dartCompileKernel: dartCompileKernel,
        windowsGUI: windowsGUI);
  } else {
    throw ArgumentError("Unknown type: $json");
  }
}