Skip to content

Commit 53bd378

Browse files
authored
Added version property to be visible as a part of decoding (#25)
1 parent 26517c4 commit 53bd378

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

lib/src/common/decoder_result.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ class DecoderResult {
3131
final int structuredAppendParity;
3232
final int structuredAppendSequenceNumber;
3333

34+
/// The QR code version as an integer, if available
35+
final int? version;
36+
3437
DecoderResult({
3538
this.rawBytes,
3639
required this.text,
3740
required this.byteSegments,
3841
required this.ecLevel,
3942
this.structuredAppendParity = -1,
4043
this.structuredAppendSequenceNumber = -1,
44+
this.version,
4145
}) : numBits = rawBytes == null ? 0 : 8 * rawBytes.length;
4246

4347
bool get hasStructuredAppend {

lib/src/qrcode/decoder/decoded_bit_stream_parser.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ class DecodedBitStreamParser {
122122
byteSegments: byteSegments.isEmpty ? null : byteSegments,
123123
ecLevel: ecLevel?.toString(),
124124
structuredAppendParity: symbolSequence,
125-
structuredAppendSequenceNumber: parityData);
125+
structuredAppendSequenceNumber: parityData,
126+
version: version.versionNumber);
126127
}
127128

128129
/// See specification GBT 18284-2000

lib/src/qrcode/qrcode_reader.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ class QRCodeReader implements Reader {
5050

5151
var result = Result(
5252
decoderResult.text, decoderResult.rawBytes, BarcodeFormat.qrCode,
53-
points: points);
53+
points: points,
54+
version: decoderResult.version);
5455
var byteSegments = decoderResult.byteSegments;
5556
if (byteSegments != null) {
5657
result.putMetadata(ResultMetadataType.byteSegments, byteSegments);

lib/src/result.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ class Result {
3131

3232
final DateTime time;
3333

34+
/// The QR code version as an integer, if available
35+
final int? version;
36+
3437
Result(this.text, this.rawBytes, this.format,
35-
{List<ResultPoint>? points, int? numBits, DateTime? time})
38+
{List<ResultPoint>? points, int? numBits, DateTime? time, this.version})
3639
: numBits = numBits ?? (rawBytes == null ? 0 : 8 * rawBytes.length),
3740
time = time ?? DateTime.now() {
3841
if (points != null) {

lib/src/result_metadata_type.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@ enum ResultMetadataType {
5050
/// If the code format supports structured append and the current scanned code is part of one then the
5151
/// parity is given with it.
5252
structuredAppendParity,
53+
54+
/// QR code version number (int)
55+
version,
5356
}

0 commit comments

Comments
 (0)