afinas-em / qr-bar-code-scanner-dialog

Plugin to scan Bar/QR code easily with Flutter.
Apache License 2.0
9 stars 21 forks source link

How to shorten the result? #6

Open falcorrus opened 11 months ago

falcorrus commented 11 months ago

Hi. I implemented it, thank you!! The result looks like "Code scanned = 234234234234". How can I get "234234234234" without thе additional text? 2023-12-03_22-11-05

japarico commented 8 months ago

final String? newCode = code?.replaceAll('Code scanned = ', '').trim();

UsamaSarwar commented 3 months ago

You may use this function...

final _qrBarCodeScannerDialogPlugin = QrBarCodeScannerDialog();
String? scanQRCode(context) {
    String? result;
    Future.delayed(const Duration(milliseconds: 1), () async {
      _qrBarCodeScannerDialogPlugin.getScannedQrBarCode(
          context: context,
          onCode: (code) async {
            if (code == null) {
              return null;
            }
            if (kIsWeb) {
              result = code.substring(15);
            } else {
              result = code;
            }
            return result;
          });
    });
    return null;
  }

CC: @falcorrus