qr_validacion.dart 534 B

1234567891011121314151617181920212223
  1. class QRValidacion {
  2. static final RegExp _regExp =
  3. RegExp(r'^(SUPER)%([\w\s\-]*)%([\w\s\-]*)%(GAS)$');
  4. static Map<String, String?> validarQR(String qrCode) {
  5. final RegExpMatch? match = _regExp.firstMatch(qrCode);
  6. if (match != null) {
  7. return {
  8. 'isValid': 'true',
  9. 'idEmpresa': match.group(2),
  10. 'numeroUnidad': match.group(3),
  11. };
  12. } else {
  13. return {
  14. 'isValid': 'false',
  15. 'idEmpresa': 'Desconocido',
  16. 'numeroUnidad': 'Desconocido',
  17. };
  18. }
  19. }
  20. }