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
|
## v1.3.0
|
||||||
|
|
||||||
- chore: add funding (The one with the braid)
|
- chore: add funding (The one with the braid)
|
||||||
|
|
|
@ -23,11 +23,11 @@ class PassBarcode {
|
||||||
/// - iso-8859-1: [Latin1Codec]
|
/// - iso-8859-1: [Latin1Codec]
|
||||||
/// - utf-8: [Utf8Codec]
|
/// - utf-8: [Utf8Codec]
|
||||||
static Map<String, Encoding> supportedCodecs = {
|
static Map<String, Encoding> supportedCodecs = {
|
||||||
'iso-8859-1': Latin1Codec(),
|
'iso-8859-1': latin1,
|
||||||
'iso-8859': Latin1Codec(),
|
'iso-8859': latin1,
|
||||||
'iso8859': Latin1Codec(),
|
'iso8859': latin1,
|
||||||
'utf-8': Utf8Codec(),
|
'utf-8': utf8,
|
||||||
'utf8': Utf8Codec(),
|
'utf8': utf8,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const _allowedFormats = {
|
static const _allowedFormats = {
|
||||||
|
@ -46,10 +46,8 @@ class PassBarcode {
|
||||||
/// representations.
|
/// representations.
|
||||||
final BarcodeType format;
|
final BarcodeType format;
|
||||||
|
|
||||||
/// Message or payload to be displayed as a barcode.
|
/// Correctly encoded byte list to be displayed in the [barcode].
|
||||||
///
|
final Uint8List barcodeData;
|
||||||
/// Do not use directly, use the encoded [barcodeData] instead.
|
|
||||||
final String message;
|
|
||||||
|
|
||||||
/// Text encoding that is used to convert the message from the string
|
/// Text encoding that is used to convert the message from the string
|
||||||
/// representation to a data representation to render the barcode.
|
/// 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.
|
/// of the barcode data in case the barcode doesn’t scan.
|
||||||
final String? altText;
|
final String? altText;
|
||||||
|
|
||||||
const PassBarcode({
|
PassBarcode({
|
||||||
required this.format,
|
required this.format,
|
||||||
required this.message,
|
@Deprecated('Use [barcodeData] instead') String? message,
|
||||||
required this.messageEncoding,
|
this.messageEncoding = utf8,
|
||||||
|
Uint8List? barcodeData,
|
||||||
required this.altText,
|
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) {
|
||||||
format: _allowedFormats[json['format']]!,
|
final messageEncoding =
|
||||||
message: json['message'] as String,
|
supportedCodecs[(json['messageEncoding'] as String).toLowerCase()]!;
|
||||||
messageEncoding:
|
return PassBarcode(
|
||||||
supportedCodecs[(json['messageEncoding'] as String).toLowerCase()]!,
|
format: _allowedFormats[json['format']]!,
|
||||||
altText: json['altText'] as String?,
|
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].
|
/// Message or payload to be displayed as a barcode.
|
||||||
Uint8List get barcodeData =>
|
///
|
||||||
Uint8List.fromList(messageEncoding.encode(message));
|
/// Do not use directly, use the encoded [barcodeData] instead.
|
||||||
|
String get message => messageEncoding.decode(barcodeData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: pkpass
|
name: pkpass
|
||||||
description: A Dart native pkpass parsing library supporting checksum verification, barcode parsing, localization and much more.
|
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
|
repository: https://gitlab.com/TheOneWithTheBraid/dart_pkpass.git
|
||||||
homepage: https://gitlab.com/TheOneWithTheBraid/dart_pkpass
|
homepage: https://gitlab.com/TheOneWithTheBraid/dart_pkpass
|
||||||
issue_tracker: https://gitlab.com/TheOneWithTheBraid/dart_pkpass/-/issues
|
issue_tracker: https://gitlab.com/TheOneWithTheBraid/dart_pkpass/-/issues
|
||||||
|
@ -15,9 +15,9 @@ dependencies:
|
||||||
barcode: ^2.2.4
|
barcode: ^2.2.4
|
||||||
crypto: ^3.0.3
|
crypto: ^3.0.3
|
||||||
http: ^1.0.0
|
http: ^1.0.0
|
||||||
intl: ^0.18.1
|
intl: ^0.19.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
import_sorter: ^4.6.0
|
import_sorter: ^4.6.0
|
||||||
lints: ">= 2.0.0 < 4.0.0"
|
lints: ">=2.0.0 <4.0.0"
|
||||||
test: ^1.21.0
|
test: ^1.21.0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue