Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App close after scanning barcode

See original GitHub issue

Describe the bug I got error while scanning barcode. Barcode value is shown in dart log, but app is stopped. I dont know i wrong in implementation or that’s a bug.

Smartphone (please complete the following information):

  • Device: MI A1
  • OS: Android 9


    Process: com.mozdev.barcode_scan, PID: 15566
    java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=9001, result=0, data=Intent { (has extras) }} to activity {com.mozdev.barcode_scan/com.mozdev.barcode_scan.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void io.flutter.plugin.common.MethodChannel$Result.success(java.lang.Object)' on a null object reference
        at android.os.Handler.dispatchMessage(
        at android.os.Looper.loop(
        at java.lang.reflect.Method.invoke(Native Method)
     Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void io.flutter.plugin.common.MethodChannel$Result.success(java.lang.Object)' on a null object reference
        at com.amolg.flutterbarcodescanner.FlutterBarcodeScannerPlugin.onActivityResult(
        at io.flutter.embedding.engine.FlutterEnginePluginRegistry$FlutterEngineActivityPluginBinding.onActivityResult(
        at io.flutter.embedding.engine.FlutterEnginePluginRegistry.onActivityResult(


Future<void> scanBarcodeNormal(BuildContext context) async {
    String barcodeScanRes;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      barcodeScanRes = await FlutterBarcodeScanner.scanBarcode(
          "#ff6666", "Cancel", true, ScanMode.BARCODE);
    } on PlatformException {
      barcodeScanRes = 'Failed to get platform version.';

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _scanBarcode = barcodeScanRes;

**Dart/Flutter Log**
> I/flutter (17677): 8999909000711


      url: git://

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

bverhagencommented, Feb 8, 2020

I have exactly the same issue on a HTC U11, also with Android 9.

I observed that, when I restart the application after the crash, it prints the QR code it was scanning just before the crash. So it seems the detection actually works. The behaviour is the same in debug and release mode.

AmolGangadharecommented, Apr 25, 2021

The issue has been fixed in V 2.0.0.

Closing this as of now, feel free to open a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

App closes after scanning a Barcode · Issue #33 - GitHub
Hi, i got the problem that the scanner correctly detectes the barcode but closes the app without any error messages on Android.
Read more >
Why does my phone crash when I scan barcodes - Google Help
As I proceeded to scan my items I noticed after the first scan my pixel 4xl goes black, and the only way to...
Read more >
scan qrcode closing app instead of providing result
However, after scanning, the app immediately closes. No errors and no results. Just bye-bye.
Read more >
How to Fix Barcode Scanner Not Working - Lose It! Support
This article will explain how to troubleshoot when the barcode scanner is not working. ... This will close any apps that were running...
Read more >
Barcode Scanner - QR Scanner on the App Store - Apple
QR Code Reader & Barcode Scanner Free can be use as shopping assistant. -Jump directly to WEB ADDRESSES decoded.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found