mobile_scanner icon indicating copy to clipboard operation
mobile_scanner copied to clipboard

MissingPluginException(No implementation found for method state on channel dev.steenbakker.mobile_scanner/scanner/event)

Open prasunsultania opened this issue 2 years ago • 0 comments

I am running into below issue

MissingPluginException(No implementation found for method state on channel dev.steenbakker.mobile_scanner/scanner/event)

The Exception comes through

 MobileScannerState state = MobileScannerState
          .values[await methodChannel.invokeMethod('state') as int];

i.e. upon methodChannel.invokeMethod('state') in library

Below, is my source code for which it keeps failing whenever build is invoked.

import 'package:flutter/material.dart';
import 'package:mobile_scanner/mobile_scanner.dart';

class ScannerActivity extends StatefulWidget {
  const ScannerActivity({Key key}) : super(key: key);

  @override
  State<ScannerActivity> createState() => _ScannerActivityState();
}

class _ScannerActivityState extends State<ScannerActivity> {
  String barcodeValue;
  // MobileScannerController cameraController = MobileScannerController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Mobile Scanner'),
      ),
      body: Center(
        child: SizedBox(
          child: MobileScanner(
            fit: BoxFit.contain,
            onDetect: (barcode, args) {
              barcodeValue = barcode.rawValue;
              //debugPrint('Barcode found! $barcodeValue');
              Navigator.of(context).pop(barcodeValue);
            },
          ),
        ),
      ),
    );
  }
}

I am getting this issue on mobile on Android and is happening upon doing scan or whenever the build of widget I created above is invoked.

prasunsultania avatar Aug 28 '22 12:08 prasunsultania