pkpass 2.0.1 copy "pkpass: ^2.0.1" to clipboard
pkpass: ^2.0.1 copied to clipboard

A Dart native pkpass parsing library supporting checksum verification, barcode parsing, localization and much more.

example/pkpass_example.dart

import 'dart:io';

import 'package:intl/locale.dart';
import 'package:pkpass/pkpass.dart';

Future<int> main(List<String> args) async {
  print('Using first argument or stdin file name: ');
  final path = args.singleOrNull ?? stdin.readLineSync();
  if (path == null || path.isEmpty) {
    print('Please enter a file name or provide it as single argument.');
    return 1;
  }

  final file = File(path);
  final contents = await file.readAsBytes();

  final pass = await PassFile.parse(contents);

  final logo = pass.getLogo(
    scale: 2,
    locale: Locale.fromSubtags(languageCode: 'fr'),
  );

  print('Logo image blob length: ${logo?.length}');
  print('First barcode: ${pass.metadata.barcodes.firstOrNull?.message}');
  print('Location: ${pass.metadata.locations.firstOrNull?.relevantText}');
  print('Date: ${pass.metadata.relevantDate}');
  print(
    'Boarding pass: ${pass.metadata.boardingPass?.headerFields.firstOrNull?.getLocalizedLabel(pass, Locale.fromSubtags(languageCode: 'tlh'))}',
  );

  return 0;
}
2
likes
140
pub points
59%
popularity

Publisher

verified publisherwith-the-braid.cf

A Dart native pkpass parsing library supporting checksum verification, barcode parsing, localization and much more.

Homepage
Repository (GitLab)
View/report issues

Documentation

API reference

Funding

Consider supporting this project:

www.buymeacoffee.com

License

EUPL-1.2 (LICENSE)

Dependencies

archive, barcode, crypto, http, intl

More

Packages that depend on pkpass