juliansteenbakker / mobile_scanner

A universal scanner for Flutter based on MLKit. Uses CameraX on Android and AVFoundation on iOS.
BSD 3-Clause "New" or "Revised" License
744 stars 444 forks source link

did not scan barcode/QRcode for web #1014

Open javaone199 opened 1 month ago

javaone199 commented 1 month ago

Followed the example, and added the script to the index.html for web.

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: MobileScanner(
        controller: MobileScannerController(
          detectionSpeed: DetectionSpeed.normal,
          facing: CameraFacing.front,
          torchEnabled: true,
        ),
        onDetect: (capture) {
          final List<Barcode> barcodes = capture.barcodes;
          final Uint8List? image = capture.image;
          for (final barcode in barcodes) {
            debugPrint('Barcode found! ${barcode.rawValue}');
          }
        },
      ), 
    );
  }
}

The camera is open after permission is granted. But the app(windows, chrome web) did not scan barcode and QR code that is focused in camera. No scan window and nothing happened.

navaronbracke commented 1 month ago

Your code sample indicates that you are using an older version of mobile_scanner. Could you try this with the latest beta release? The beta 3 release does fix an issue on the web relating to the camera freezing the second time, but you should be able to test your issue with it.

nvbien2000 commented 4 weeks ago

Hi pal, check this conversation @javaone199 : https://github.com/juliansteenbakker/mobile_scanner/issues/976