mintware-de / flutter_barcode_reader

A flutter plugin for reading 2D barcodes and QR codes.
MIT License
628 stars 462 forks source link

return com.google.zxing.Result type object instead of only string #131

Closed AlexGreg closed 4 years ago

AlexGreg commented 5 years ago

in order to have also information about the type of barcode

masewo commented 5 years ago

I needed barcode format too so I forked the project and added return of barcode format: https://github.com/masewo/flutter_barcode_reader

ghost7476 commented 4 years ago

I needed barcode format too so I forked the project and added return of barcode format: https://github.com/masewo/flutter_barcode_reader

@masewo Hello, I have cloned your code, I found you just add android barcode type, will you add this in iOS?

masewo commented 4 years ago

Yes, I will do it for iOS soon.

arne-kapell commented 4 years ago

Hey, any updates on the iOS version?

masewo commented 4 years ago

@ghost7476 @mdlmlr Sorry that it took so long, but I had no iOS device to test this feature. Here I added the support for iOS: https://github.com/masewo/flutter_barcode_reader/commit/008b25d235c0b84be32679ca4dbc2576d88c120e I added code in our app to convert iOS types to Android types:

// convert barcode type coming from iOS
    if (Platform.isIOS) {
      switch (barcode["barcodeFormat"]) {
        case 'org.iso.Aztec':
          barcode["barcodeFormat"] = 'AZTEC';
          break;
        case 'org.iso.Code39':
          barcode["barcodeFormat"] = 'CODE_39';
          break;
        case 'org.iso.Code39Mod43': // will be always detected as Code39 by Apple ?!
          barcode["barcodeFormat"] = 'CODE_39';
          break;
        case 'com.intermec.Code93':
          barcode["barcodeFormat"] = 'CODE_93';
          break;
        case 'org.iso.Code128':
          barcode["barcodeFormat"] = 'CODE_128';
          break;
        case 'org.iso.DataMatrix':
          barcode["barcodeFormat"] = 'DATA_MATRIX';
          break;
        case 'org.gs1.EAN-8':
          barcode["barcodeFormat"] = 'EAN_8';
          break;
        case 'org.gs1.EAN-13':
          if (barcode["barcode"].startsWith('0')) {
            barcode["barcode"] = barcode["barcode"].substring(1);
            barcode["barcodeFormat"] = 'UPC_A';
          } else {
            barcode["barcodeFormat"] = 'EAN_13';
          }
          break;
        case 'org.ansi.Interleaved2of5':
          barcode["barcodeFormat"] = 'ITF';
          break;
        case 'org.gs1.ITF14':
          barcode["barcodeFormat"] = 'ITF';
          break;
        case 'org.iso.PDF417':
          barcode["barcodeFormat"] = 'PDF_417';
          break;
        case 'org.iso.QRCode':
          barcode["barcodeFormat"] = 'QR_CODE';
          break;
        case 'org.gs1.UPC-E':
          barcode["barcodeFormat"] = 'UPC_E';
          break;
        default:
          break;
      // support missing for:
      // CODABAR, MAXICODE, RSS_14, RSS_EXPANDED, UPC_EAN_EXTENSION
      }
    }
devtronic commented 4 years ago

I'll rewrite the platform communication and extend it with more properties.

devtronic commented 4 years ago

https://pub.dev/packages/barcode_scan/versions/3.0.0-dev.1