passesFromBytes static method
Parses a .pkpasses
to a list of PkPasses.
The mimetype of that file is application/vnd.apple.pkpasses
.
A .pkpasses
file cna contain up to ten PkPasses.
Setting skipVerification
to true disables any checksum or signature
verification and validation.
Read more at:
Implementation
// TODO(ueman): Detect whether it's maybe just a single pass, and then
// gracefully fall back to just parsing the PkPass file.
// TODO(ueman): Provide an async method for this.
static List<PkPass> passesFromBytes(
final Uint8List bytes, {
bool skipChecksumVerification = false,
bool skipSignatureVerification = false,
}) {
if (bytes.isEmpty) {
throw EmptyBytesException();
}
ZipDecoder decoder = ZipDecoder();
final archive = decoder.decodeBytes(bytes);
final pkPasses =
archive.files.where((file) => file.name.endsWith('.pkpass')).toList();
return pkPasses
.map(
(file) => fromBytes(
file.binaryContent,
skipChecksumVerification: skipChecksumVerification,
skipSignatureVerification: skipSignatureVerification,
),
)
.toList();
}