mirror of
https://gitlab.com/TheOneWithTheBraid/dart_pkpass.git
synced 2025-07-05 12:58:47 +00:00
Merge branch 'braid/barcode-binary-data' into 'main'
refactor: use binary barcode data by default See merge request TheOneWithTheBraid/dart_pkpass!1
This commit is contained in:
commit
b7563ce18a
3 changed files with 35 additions and 26 deletions
|
@ -1,3 +1,7 @@
|
|||
## v2.0.2
|
||||
|
||||
- refactor: use binary barcode data by default (The one with the braid)
|
||||
|
||||
## v1.3.0
|
||||
|
||||
- chore: add funding (The one with the braid)
|
||||
|
|
|
@ -23,11 +23,11 @@ class PassBarcode {
|
|||
/// - iso-8859-1: [Latin1Codec]
|
||||
/// - utf-8: [Utf8Codec]
|
||||
static Map<String, Encoding> supportedCodecs = {
|
||||
'iso-8859-1': Latin1Codec(),
|
||||
'iso-8859': Latin1Codec(),
|
||||
'iso8859': Latin1Codec(),
|
||||
'utf-8': Utf8Codec(),
|
||||
'utf8': Utf8Codec(),
|
||||
'iso-8859-1': latin1,
|
||||
'iso-8859': latin1,
|
||||
'iso8859': latin1,
|
||||
'utf-8': utf8,
|
||||
'utf8': utf8,
|
||||
};
|
||||
|
||||
static const _allowedFormats = {
|
||||
|
@ -46,10 +46,8 @@ class PassBarcode {
|
|||
/// representations.
|
||||
final BarcodeType format;
|
||||
|
||||
/// Message or payload to be displayed as a barcode.
|
||||
///
|
||||
/// Do not use directly, use the encoded [barcodeData] instead.
|
||||
final String message;
|
||||
/// Correctly encoded byte list to be displayed in the [barcode].
|
||||
final Uint8List barcodeData;
|
||||
|
||||
/// Text encoding that is used to convert the message from the string
|
||||
/// representation to a data representation to render the barcode.
|
||||
|
@ -68,22 +66,29 @@ class PassBarcode {
|
|||
/// of the barcode data in case the barcode doesn’t scan.
|
||||
final String? altText;
|
||||
|
||||
const PassBarcode({
|
||||
PassBarcode({
|
||||
required this.format,
|
||||
required this.message,
|
||||
required this.messageEncoding,
|
||||
@Deprecated('Use [barcodeData] instead') String? message,
|
||||
this.messageEncoding = utf8,
|
||||
Uint8List? barcodeData,
|
||||
required this.altText,
|
||||
});
|
||||
}) : barcodeData =
|
||||
Uint8List.fromList(barcodeData ?? messageEncoding.encode(message!));
|
||||
|
||||
factory PassBarcode.fromJson(Map<String, Object?> json) => PassBarcode(
|
||||
factory PassBarcode.fromJson(Map<String, Object?> json) {
|
||||
final messageEncoding =
|
||||
supportedCodecs[(json['messageEncoding'] as String).toLowerCase()]!;
|
||||
return PassBarcode(
|
||||
format: _allowedFormats[json['format']]!,
|
||||
message: json['message'] as String,
|
||||
messageEncoding:
|
||||
supportedCodecs[(json['messageEncoding'] as String).toLowerCase()]!,
|
||||
barcodeData:
|
||||
Uint8List.fromList(messageEncoding.encode(json['message'] as String)),
|
||||
messageEncoding: messageEncoding,
|
||||
altText: json['altText'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
/// Correctly encoded byte list to be displayed in the [barcode].
|
||||
Uint8List get barcodeData =>
|
||||
Uint8List.fromList(messageEncoding.encode(message));
|
||||
/// Message or payload to be displayed as a barcode.
|
||||
///
|
||||
/// Do not use directly, use the encoded [barcodeData] instead.
|
||||
String get message => messageEncoding.decode(barcodeData);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: pkpass
|
||||
description: A Dart native pkpass parsing library supporting checksum verification, barcode parsing, localization and much more.
|
||||
version: 1.3.0
|
||||
version: 2.0.0
|
||||
repository: https://gitlab.com/TheOneWithTheBraid/dart_pkpass.git
|
||||
homepage: https://gitlab.com/TheOneWithTheBraid/dart_pkpass
|
||||
issue_tracker: https://gitlab.com/TheOneWithTheBraid/dart_pkpass/-/issues
|
||||
|
@ -15,9 +15,9 @@ dependencies:
|
|||
barcode: ^2.2.4
|
||||
crypto: ^3.0.3
|
||||
http: ^1.0.0
|
||||
intl: ^0.18.1
|
||||
intl: ^0.19.0
|
||||
|
||||
dev_dependencies:
|
||||
import_sorter: ^4.6.0
|
||||
lints: ">= 2.0.0 < 4.0.0"
|
||||
lints: ">=2.0.0 <4.0.0"
|
||||
test: ^1.21.0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue