juliuscanute / qr_code_scanner

QR Code Scanner for Flutter
BSD 2-Clause "Simplified" License
996 stars 742 forks source link

IOS camera gets stuck when exit (OnStop) the application and come back (OnStart) [BUG] #304

Open Chakib-Temal opened 3 years ago

Chakib-Temal commented 3 years ago

Describe the bug there is a bug which occurs only on the IOS and not on android when i launch the app, everything is fine but once I exit the application (OnStop) and come back afterwards (OnStart) (so without complete closing), the camera gets stuck and the QrView displays last image camera detected before exiting the application

this error exists only on Ios and not on Android

Information build Stable Flutter 1.22.0

temporary solution implements WidgetsBindingObserver to use widget lifecycle events and refresh your page

class PageState extends State<HomePage> with WidgetsBindingObserver {

@override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
  }

/// imlementation WidgetsBindingObserver
@override
  void didChangeAppLifecycleState(AppLifecycleState state) async{
    super.didChangeAppLifecycleState(state);
    if (state == AppLifecycleState.resumed) {
       refreshPage();
    }
  }

@override
  void dispose() {
    super.dispose();
    WidgetsBinding.instance.removeObserver(this);
  }
}
smofe commented 3 years ago

I have the same problem on an iPhone 6s with iOS 13.5.1.

Thank you very much for the temporary solution, it works great for now!