ZipFile.fromJson constructor
ZipFile.fromJson(
- Object? json_
Returns a new instance from a JSON value. May throw if the value does not have the expected structure.
Implementation
factory ZipFile.fromJson(Object? json_) {
final json = json_ is Map
? _spec.fields.map((f) => json_[f.label]).toList(growable: false)
: json_;
return switch (json) {
[
final compressionMethod,
final lastModifiedTime,
final permissions,
final comment,
final file,
final crc32,
final compressedSize,
final extraData,
final isDir,
final enclosedName
] ||
(
final compressionMethod,
final lastModifiedTime,
final permissions,
final comment,
final file,
final crc32,
final compressedSize,
final extraData,
final isDir,
final enclosedName
) =>
ZipFile(
compressionMethod: ZipCompressionMethod.fromJson(compressionMethod),
lastModifiedTime: bigIntFromJson(lastModifiedTime),
permissions:
Option.fromJson(permissions, (some) => some! as int).value,
comment:
comment is String ? comment : (comment! as ParsedString).value,
file: FileBytes.fromJson(file),
crc32: crc32! as int,
compressedSize: bigIntFromJson(compressedSize),
extraData: (extraData is Uint8List
? extraData
: Uint8List.fromList((extraData! as List).cast())),
isDir: isDir! as bool,
enclosedName: Option.fromJson(
enclosedName,
(some) =>
some is String ? some : (some! as ParsedString).value).value,
),
_ => throw Exception('Invalid JSON $json_')
};
}