mobile_scanner icon indicating copy to clipboard operation
mobile_scanner copied to clipboard

A black screen on IOS 15.4.1

Open shijia2118 opened this issue 2 years ago • 13 comments

When I first entered the page on IOS 15.4.1, it gave me a black screen. I need to switch to the background and come back for it to work. But it is ok on Android. Please hepl me,what can i do?Thank you!

shijia2118 avatar May 19 '22 03:05 shijia2118

up

vikazuo avatar May 20 '22 20:05 vikazuo

same issue on web

I found a solution that works for me

just play camera in initstate and stop it in dispose by controller:

MobileScannerController? cameraController;

  @override
    void initState() {
  super.initState();
  cameraController = MobileScannerController();
  cameraController!.start()
}

 @override
 void dispose() {
  cameraController?.stop();
   cameraController?.dispose();
   super.dispose();
  }

   @override
    Widget build(BuildContext context) {
     return   MobileScanner(
      controller: cameraController,
       fit: BoxFit.cover,
        onDetect: (barcode, args) {
        setState(() {
         this.barcode = barcode.rawValue;
          });
         },
      );
    }

royacodes avatar May 22 '22 10:05 royacodes

up

dogusdicle avatar May 22 '22 10:05 dogusdicle

same issue on web

I found a solution that works for me

just play camera in initstate and stop it in dispose by controller:

MobileScannerController? cameraController;

  @override
    void initState() {
  super.initState();
  cameraController = MobileScannerController();
  cameraController!.start()
}

 @override
 void dispose() {
  cameraController?.stop();
   cameraController?.dispose();
   super.dispose();
  }

   @override
    Widget build(BuildContext context) {
     return   MobileScanner(
      controller: cameraController,
       fit: BoxFit.cover,
        onDetect: (barcode, args) {
        setState(() {
         this.barcode = barcode.rawValue;
          });
         },
      );
    }

Didn't work for me on Web. Android doesn't have this problem

Masishta avatar May 26 '22 13:05 Masishta

I tried using the example app on my iPad running iOS 15.5, but i don't have any problems. Do you maybe have any code to reproduce this issue?

juliansteenbakker avatar May 31 '22 08:05 juliansteenbakker

Same issue on IOS 15.5

nhatdo2110 avatar Jun 01 '22 10:06 nhatdo2110

Showing black screen while open second time scanner.

Hardik3143 avatar Jun 02 '22 06:06 Hardik3143

Same issue here.

Flutter 2.8.1 Dart 2.15.1

Create a MobileScanner(onDetect: (p0, p1) {}) Error: MobileScanner: Called start() while already started!

Black screen of death. Sometimes I can get it to pop up if I try navigator.pop, but it's not 100%.

Luzzotica avatar Jun 16 '22 22:06 Luzzotica

Removing start from MobileScannerController resolves the issue for us

MobileScannerController({
    this.facing = CameraFacing.back,
    this.ratio,
    this.torchEnabled,
    this.formats,
  }) {
    // In case a new instance is created before calling dispose()
    if (_controllerHashcode != null) {
      stop();
    }
    _controllerHashcode = hashCode;

    cameraFacingState = ValueNotifier(facing);

    // Sets analyze mode and barcode stream
    barcodesController = StreamController.broadcast(
        // onListen: () => setAnalyzeMode(AnalyzeMode.barcode.index),
        // onCancel: () => setAnalyzeMode(AnalyzeMode.none.index),
        );

    // start(); //! <- removed

    // Listen to events from the platform specific code
    events = eventChannel
        .receiveBroadcastStream()
        .listen((data) => handleEvent(data as Map));
  }

Edit: This was only tested on iOS 15.5 and android 10!

hnord-vdx avatar Jun 17 '22 11:06 hnord-vdx

I've tried all of the solutions posted, nothing works. What I did and immediately worked is, onReady() just stop the camera controller.

Notice that I am using GetX.

Here my code (and fixes all of these issues), though I still get a warning Called stop() while already stopped!, but it works.

@override
  void onReady() {
    scanController.stop();
    super.onReady();
  }

pzehle avatar Aug 01 '22 11:08 pzehle

I have the same issue on iOS

kamami avatar Aug 15 '22 13:08 kamami

I am also getting the same issue on iOS 15.3.1 with Flutter 3

ThamMK avatar Aug 18 '22 04:08 ThamMK

Same Issue !!

liamsammut97 avatar Aug 24 '22 11:08 liamsammut97

Since there has been lots of updates, please check with latest version 3.0.0-beta.4 and comment if this issue still exists.

juliansteenbakker avatar Dec 13 '22 20:12 juliansteenbakker