isBarcode property
Checks if this string represents a barcode.
Supports:
- Traditional numeric barcodes (digits only, length >= 8)
- GS1 barcodes with FNC1 character (\x1D or \x241D)
- GS1 bracketed AI format like (01)04044782317112(17)270101
- GS1 Digital Links (https:// URLs containing GS1 AIs like /01/)
Implementation
bool get isBarcode {
final String query = trim();
if (query.isEmpty) {
return false;
}
// Traditional numeric barcode
if (_numericBarcodeRegExp.hasMatch(query)) {
return true;
}
// GS1 bracketed AI format like (01)04044782317112(17)270101
if (_gs1BracketedRegExp.hasMatch(query)) {
return true;
}
// GS1 barcode with FNC1
if (query.contains('\x1D') || query.contains('\u241D')) {
return true;
}
// GS1 Digital Link (URLs with GS1 AIs)
if ((query.startsWith('http://') || query.startsWith('https://')) &&
_containsGs1ApplicationIdentifiers(query)) {
return true;
}
return false;
}