|
|
|
@ -35,22 +35,24 @@ abstract class Format {
|
|
|
|
|
static const int any = oneDCodes | twoDCodes; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
extension EccSupportedExtension on int { |
|
|
|
|
extension CodeFormat on int { |
|
|
|
|
String get name => barcodeNames[this] ?? 'Unknown'; |
|
|
|
|
|
|
|
|
|
// The width divided by the height of the barcode |
|
|
|
|
double get ratio => barcodeRatios[this] ?? 1.0; |
|
|
|
|
String get demoText => barcodeDemoText[this] ?? ''; |
|
|
|
|
int get maxTextLength => barcodeMaxTextLengths[this] ?? 0; |
|
|
|
|
bool get isSupportedEccLevel => eccSupported.contains(this); |
|
|
|
|
|
|
|
|
|
static final List<int> eccSupported = <int>[ |
|
|
|
|
Format.qrCode, |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
extension CodeFormat on Format { |
|
|
|
|
String get name => formatNames[this] ?? 'Unknown'; |
|
|
|
|
|
|
|
|
|
static final List<int> writerFormats = <int>[ |
|
|
|
|
static final List<int> supportedEncodeFormats = <int>[ |
|
|
|
|
Format.qrCode, |
|
|
|
|
Format.dataMatrix, |
|
|
|
|
Format.aztec, |
|
|
|
|
Format.pdf417, |
|
|
|
|
// Format.pdf417, |
|
|
|
|
Format.codabar, |
|
|
|
|
Format.code39, |
|
|
|
|
Format.code93, |
|
|
|
@ -66,7 +68,7 @@ extension CodeFormat on Format {
|
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
final Map<int, String> formatNames = <int, String>{ |
|
|
|
|
final Map<int, String> barcodeNames = <int, String>{ |
|
|
|
|
Format.none: 'None', |
|
|
|
|
Format.aztec: 'Aztec', |
|
|
|
|
Format.codabar: 'CodaBar', |
|
|
|
@ -88,3 +90,60 @@ final Map<int, String> formatNames = <int, String>{
|
|
|
|
|
Format.twoDCodes: 'TwoD', |
|
|
|
|
Format.any: 'Any', |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
final Map<int, double> barcodeRatios = <int, double>{ |
|
|
|
|
Format.aztec: 3.0 / 3.0, // recommended ratio: 3:3 (square) |
|
|
|
|
Format.codabar: 3.0 / 1.0, // recommended ratio: 3:1 |
|
|
|
|
Format.code39: 3.0 / 1.0, // recommended ratio: 3:1 |
|
|
|
|
Format.code93: 3.0 / 1.0, // recommended ratio: 3:1 |
|
|
|
|
Format.code128: 2.0 / 1.0, // recommended ratio: 2:1 |
|
|
|
|
Format.dataBar: 3.0 / 1.0, // recommended ratio: 3:1 |
|
|
|
|
Format.dataBarExpanded: 1.0 / 1.0, // recommended ratio: 1:1 (square) |
|
|
|
|
Format.dataMatrix: 3.0 / 3.0, // recommended ratio: 3:3 (square) |
|
|
|
|
Format.ean8: 3.0 / 1.0, // recommended ratio: 3:1 |
|
|
|
|
Format.ean13: 3.0 / 1.0, // recommended ratio: 3:1 |
|
|
|
|
Format.itf: 3.0 / 1.0, // recommended ratio: 3:1 |
|
|
|
|
Format.maxiCode: 3.0 / 3.0, // recommended ratio: 3:3 (square) |
|
|
|
|
Format.pdf417: 3.0 / 1.0, // recommended ratio: 3:1 |
|
|
|
|
Format.qrCode: 3.0 / 3.0, // recommended ratio: 3:3 (square) |
|
|
|
|
Format.upca: 3.0 / 1.0, // recommended ratio: 3:1 |
|
|
|
|
Format.upce: 1.0 / 1.0, // recommended ratio: 1:1 (square) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
final Map<int, String> barcodeDemoText = <int, String>{ |
|
|
|
|
Format.aztec: 'This is an Aztec Code', |
|
|
|
|
Format.codabar: 'A123456789B', |
|
|
|
|
Format.code39: 'ABC-1234', |
|
|
|
|
Format.code93: 'ABC-1234-/+', |
|
|
|
|
Format.code128: 'ABC-abc-1234', |
|
|
|
|
Format.dataBar: '0123456789012', |
|
|
|
|
Format.dataBarExpanded: '011234567890123-ABCabc', |
|
|
|
|
Format.dataMatrix: 'This is a Data Matrix', |
|
|
|
|
Format.ean8: '9031101', |
|
|
|
|
Format.ean13: '978020137962', |
|
|
|
|
Format.itf: '00012345600012', |
|
|
|
|
Format.maxiCode: 'This is a MaxiCode', |
|
|
|
|
Format.pdf417: 'This is a PDF417', |
|
|
|
|
Format.qrCode: 'This is a QR Code', |
|
|
|
|
Format.upca: '72527273070', |
|
|
|
|
Format.upce: '0123456', |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
final Map<int, int> barcodeMaxTextLengths = <int, int>{ |
|
|
|
|
Format.aztec: 3832, |
|
|
|
|
Format.codabar: 20, |
|
|
|
|
Format.code39: 43, |
|
|
|
|
Format.code93: 47, |
|
|
|
|
Format.code128: 2046, |
|
|
|
|
Format.dataBar: 74, |
|
|
|
|
Format.dataBarExpanded: 4107, |
|
|
|
|
Format.dataMatrix: 2335, |
|
|
|
|
Format.ean8: 8, |
|
|
|
|
Format.ean13: 13, |
|
|
|
|
Format.itf: 20, |
|
|
|
|
Format.maxiCode: 30, |
|
|
|
|
Format.pdf417: 2953, |
|
|
|
|
Format.qrCode: 4296, |
|
|
|
|
Format.upca: 12, |
|
|
|
|
Format.upce: 8, |
|
|
|
|
}; |
|
|
|
|