AmolGangadhare / flutter_barcode_scanner

Barcode scanner plugin for flutter. Supports barcode scanning for Android and iOS
https://pub.dev/packages/flutter_barcode_scanner
MIT License
379 stars 453 forks source link

Barcode scanner after invoking shows just grey screen #222

Closed M1chlCZ closed 2 years ago

M1chlCZ commented 3 years ago

Describe the bug After I fire up the barcode scanner by example provided by the page on pub.dev I am only getting grey screen. To Reproduce Steps to reproduce the behavior:

    try {
      String _content = await FlutterBarcodeScanner.scanBarcode(
          Colors.white24.toString(), "CANCEL", true, ScanMode.DEFAULT);
      setState(() {
        _controllerAddress.text = _content;
      });
    } on PlatformException catch (e) {
      print('Error: $e');
    } on FormatException {
      print('User pressed "back" button before scanning');
    } catch (e) {
      print('Error: $e');
    }
  }

Expected behavior To show QR scanner.

Smartphone (please complete the following information):

sarahk commented 3 years ago

I had that too, could run the example code but not mine. I'd changed function names, exceptions. Once I changed all that back it worked. I need to go back and replicate to identify what didn't like being edited.

Batflash5 commented 2 years ago

Colors.white24.toString() - this is the one which causes error.

The first argument of FlutterBarcodeScanner.scanBarcode() is a String(Hex value of color with a '#' replacing '0x').

Example: String _content = FlutterBarcodeScanner.scanBarcode('#FF4CAF50', "CANCEL", true, ScanMode.DEFAULT);

Hope it helps.

M1chlCZ commented 2 years ago

@Batflash5 Well that worked, I feel stupid. I already move on to my own solution, out of the curiosity and personal project. However yeah, sometimes reading helps.

So thank you and this is solved.