Showing
1 changed file
with
57 additions
and
82 deletions
| 1 | +/// This enum defines the different barcode formats. | ||
| 1 | enum BarcodeFormat { | 2 | enum BarcodeFormat { |
| 2 | - /// Barcode format unknown to the current SDK. | ||
| 3 | - /// | ||
| 4 | - /// Constant Value: -1 | ||
| 5 | - unknown, | 3 | + /// A barcode format that represents all unknown formats. |
| 4 | + unknown(-1), | ||
| 6 | 5 | ||
| 7 | - /// Barcode format constant representing the union of all supported formats. | ||
| 8 | - /// | ||
| 9 | - /// Constant Value: 0 | ||
| 10 | - all, | 6 | + /// A barcode format that represents all known formats. |
| 7 | + all(0), | ||
| 11 | 8 | ||
| 12 | /// Barcode format constant for Code 128. | 9 | /// Barcode format constant for Code 128. |
| 13 | - /// | ||
| 14 | - /// Constant Value: 1 | ||
| 15 | - code128, | 10 | + code128(1), |
| 16 | 11 | ||
| 17 | /// Barcode format constant for Code 39. | 12 | /// Barcode format constant for Code 39. |
| 18 | - /// | ||
| 19 | - /// Constant Value: 2 | ||
| 20 | - code39, | 13 | + code39(2), |
| 21 | 14 | ||
| 22 | /// Barcode format constant for Code 93. | 15 | /// Barcode format constant for Code 93. |
| 23 | - /// | ||
| 24 | - /// Constant Value: 4 | ||
| 25 | - code93, | 16 | + code93(4), |
| 26 | 17 | ||
| 27 | /// Barcode format constant for Codabar. | 18 | /// Barcode format constant for Codabar. |
| 28 | - /// | ||
| 29 | - /// Constant Value: 8 | ||
| 30 | - codebar, | 19 | + codebar(8), |
| 31 | 20 | ||
| 32 | /// Barcode format constant for Data Matrix. | 21 | /// Barcode format constant for Data Matrix. |
| 33 | - /// | ||
| 34 | - /// Constant Value: 16 | ||
| 35 | - dataMatrix, | 22 | + dataMatrix(16), |
| 36 | 23 | ||
| 37 | /// Barcode format constant for EAN-13. | 24 | /// Barcode format constant for EAN-13. |
| 38 | - /// | ||
| 39 | - /// Constant Value: 32 | ||
| 40 | - ean13, | 25 | + ean13(32), |
| 41 | 26 | ||
| 42 | /// Barcode format constant for EAN-8. | 27 | /// Barcode format constant for EAN-8. |
| 43 | - /// | ||
| 44 | - /// Constant Value: 64 | ||
| 45 | - ean8, | 28 | + ean8(64), |
| 46 | 29 | ||
| 47 | /// Barcode format constant for ITF (Interleaved Two-of-Five). | 30 | /// Barcode format constant for ITF (Interleaved Two-of-Five). |
| 48 | - /// | ||
| 49 | - /// Constant Value: 128 | ||
| 50 | - itf, | 31 | + itf(128), |
| 51 | 32 | ||
| 52 | - /// Barcode format constant for QR Code. | ||
| 53 | - /// | ||
| 54 | - /// Constant Value: 256 | ||
| 55 | - qrCode, | 33 | + /// Barcode format constant for QR Codes. |
| 34 | + qrCode(256), | ||
| 56 | 35 | ||
| 57 | /// Barcode format constant for UPC-A. | 36 | /// Barcode format constant for UPC-A. |
| 58 | - /// | ||
| 59 | - /// Constant Value: 512 | ||
| 60 | - upcA, | 37 | + upcA(512), |
| 61 | 38 | ||
| 62 | /// Barcode format constant for UPC-E. | 39 | /// Barcode format constant for UPC-E. |
| 63 | - /// | ||
| 64 | - /// Constant Value: 1024 | ||
| 65 | - upcE, | 40 | + upcE(1024), |
| 66 | 41 | ||
| 67 | /// Barcode format constant for PDF-417. | 42 | /// Barcode format constant for PDF-417. |
| 68 | - /// | ||
| 69 | - /// Constant Value: 2048 | ||
| 70 | - pdf417, | 43 | + pdf417(2048), |
| 71 | 44 | ||
| 72 | /// Barcode format constant for AZTEC. | 45 | /// Barcode format constant for AZTEC. |
| 73 | - /// | ||
| 74 | - /// Constant Value: 4096 | ||
| 75 | - aztec, | ||
| 76 | -} | 46 | + aztec(4096); |
| 47 | + | ||
| 48 | + const BarcodeFormat(this.rawValue); | ||
| 77 | 49 | ||
| 78 | -extension BarcodeValue on BarcodeFormat { | ||
| 79 | - int get rawValue { | ||
| 80 | - switch (this) { | ||
| 81 | - case BarcodeFormat.unknown: | ||
| 82 | - return -1; | ||
| 83 | - case BarcodeFormat.all: | ||
| 84 | - return 0; | ||
| 85 | - case BarcodeFormat.code128: | ||
| 86 | - return 1; | ||
| 87 | - case BarcodeFormat.code39: | ||
| 88 | - return 2; | ||
| 89 | - case BarcodeFormat.code93: | ||
| 90 | - return 4; | ||
| 91 | - case BarcodeFormat.codebar: | ||
| 92 | - return 8; | ||
| 93 | - case BarcodeFormat.dataMatrix: | ||
| 94 | - return 16; | ||
| 95 | - case BarcodeFormat.ean13: | ||
| 96 | - return 32; | ||
| 97 | - case BarcodeFormat.ean8: | ||
| 98 | - return 64; | ||
| 99 | - case BarcodeFormat.itf: | ||
| 100 | - return 128; | ||
| 101 | - case BarcodeFormat.qrCode: | ||
| 102 | - return 256; | ||
| 103 | - case BarcodeFormat.upcA: | ||
| 104 | - return 512; | ||
| 105 | - case BarcodeFormat.upcE: | ||
| 106 | - return 1024; | ||
| 107 | - case BarcodeFormat.pdf417: | ||
| 108 | - return 2048; | ||
| 109 | - case BarcodeFormat.aztec: | ||
| 110 | - return 4096; | 50 | + factory BarcodeFormat.fromRawValue(int value) { |
| 51 | + switch (value) { | ||
| 52 | + case 0: | ||
| 53 | + return BarcodeFormat.all; | ||
| 54 | + case 1: | ||
| 55 | + return BarcodeFormat.code128; | ||
| 56 | + case 2: | ||
| 57 | + return BarcodeFormat.code39; | ||
| 58 | + case 4: | ||
| 59 | + return BarcodeFormat.code93; | ||
| 60 | + case 8: | ||
| 61 | + return BarcodeFormat.codebar; | ||
| 62 | + case 16: | ||
| 63 | + return BarcodeFormat.dataMatrix; | ||
| 64 | + case 32: | ||
| 65 | + return BarcodeFormat.ean13; | ||
| 66 | + case 64: | ||
| 67 | + return BarcodeFormat.ean8; | ||
| 68 | + case 128: | ||
| 69 | + return BarcodeFormat.itf; | ||
| 70 | + case 256: | ||
| 71 | + return BarcodeFormat.qrCode; | ||
| 72 | + case 512: | ||
| 73 | + return BarcodeFormat.upcA; | ||
| 74 | + case 1024: | ||
| 75 | + return BarcodeFormat.upcE; | ||
| 76 | + case 2048: | ||
| 77 | + return BarcodeFormat.pdf417; | ||
| 78 | + case 4096: | ||
| 79 | + return BarcodeFormat.aztec; | ||
| 80 | + case -1: | ||
| 81 | + default: | ||
| 82 | + return BarcodeFormat.unknown; | ||
| 111 | } | 83 | } |
| 112 | } | 84 | } |
| 85 | + | ||
| 86 | + /// The raw value of the barcode format. | ||
| 87 | + final int rawValue; | ||
| 113 | } | 88 | } |
-
Please register or login to post a comment