Closed LarYoungruu closed 3 years ago
Confirming same situation. Green dot does not disappear in status bar.
Like a temporary solution I've added controller.pauseCamera();
before disposing controller;
Hey @leanhro2812 and @mortifactor, I'm using the latest version of this package on a production app for iOS and Android and I'm not experiencing this problem.
Can you please post here a sample code that can reproduce your problem? This will help us to investigate about the problem 😃
Thanks
Hey @leanhro2812 and @mortifactor, I'm using the latest version of this package on a production app for iOS and Android and I'm not experiencing this problem.
Can you please post here a sample code that can reproduce your problem? This will help us to investigate about the problem 😃
Thanks
In Android it is difficult to realize this But on iOS at version 14.0 and above You will easily see the Green dot indicates the camera is active
Confirming same situation. Green dot does not disappear in status bar. Like a temporary solution I've added
controller.pauseCamera();
before disposing controller;
I tried doing the pauseCamera approach before writing the article about this error .. But doesn't seem to solve the problem .. The camera is still working. Leading to users using the application for a long time, the device will be very hot and drain a lot of battery
I perfectly understood your problem but without any sample I cannot help you.
As I have already told you before I'm using this package on production and there is not this issue anymore on iOS. If you can provide me a sample code I can try to investigate about this issue.
Thank you @leanhro2812 but it seems that in your code there is not the implementation of _onQRViewCreated
and there is not also the controller.dispose()
method that need to close the camera stream.
I perfectly understood your problem but without any sample I cannot help you.
As I have already told you before I'm using this package on production and there is not this issue anymore on iOS. If you can provide me a sample code I can try to investigate about this issue.
Thanks for the reply..
I proceed to redirect the page to the QRViewCreate And then the scanner screen is displayed. but then I left the page by pop () then I can leave QRViewCreate, everything has nothing to say until I update my Iphone to version 14.0 and discover that the camera is still working (Green dot )..
Navigator.pushNamed(context, '/QRViewCreate');
class QRViewCreate extends StatefulWidget {
const QRViewCreate({
Key key,
}) : super(key: key);
@override
State<StatefulWidget> createState() => _QRViewCreateState();
}
class _QRViewCreateState extends State<QRViewCreate> {
QRViewController controller;
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
String scanData;
@override
void dispose() {
controller?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: QRView(
key: qrKey,
onQRViewCreated: _onQRViewCreated,
overlay: QrScannerOverlayShape(
borderColor: Colors.red,
borderRadius: 10,
borderLength: 30,
borderWidth: 10,
cutOutSize: 300,
),
),
),
);
}
void _onQRViewCreated(QRViewController controller) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
this.controller = controller;
controller.scannedDataStream.listen((scanData) {
if (this.scanData != scanData.toString()) {
this.scanData = scanData.toString();
Navigator.of(context).pop(this.scanData);
}
});
});
}
}
Thank you @leanhro2812 but it seems that in your code there is not the implementation of
_onQRViewCreated
and there is not also thecontroller.dispose()
method that need to close the camera stream.
Sorry for providing missing code. Please review the comment above and I have added it
I have tried creating a new project Use the latest version of the library. Will the camera really be stopped after dispose?
I will try out your sample on a real iOS device as soon as I have a free moment
I will try out your sample on a real iOS device as soon as I have a free moment
Thanks for the things from you!
I tried your code on a sample app and it works with no problem with my iPhone XS with iOS 14.2. Here the code:
import 'package:flutter/material.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Test'),
),
body: Center(
child: Column(
children: [
RaisedButton(
child: Text('Open Qr Page'),
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(builder: (context) => QRViewCreate()),
),
),
],
),
),
);
}
}
class QRViewCreate extends StatefulWidget {
const QRViewCreate({
Key key,
}) : super(key: key);
@override
State<StatefulWidget> createState() => _QRViewCreateState();
}
class _QRViewCreateState extends State<QRViewCreate> {
QRViewController controller;
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
String scanData;
@override
void dispose() {
controller?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('QrPage'),
),
body: Container(
child: QRView(
key: qrKey,
onQRViewCreated: _onQRViewCreated,
overlay: QrScannerOverlayShape(
borderColor: Colors.red,
borderRadius: 10,
borderLength: 30,
borderWidth: 10,
cutOutSize: 300,
),
),
),
);
}
void _onQRViewCreated(QRViewController controller) {
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
this.controller = controller;
controller.scannedDataStream.listen((scanData) {
if (this.scanData != scanData.toString()) {
this.scanData = scanData.toString();
Navigator.of(context).pop(this.scanData);
}
});
});
}
}
iPhone 12 Pro Max iOS 14.4 qr_code_scanner: ^0.3.1
@enricobenedos There are actually quite a few people with the same problem with me. Will you miss anything? Real device with version 14.0 or higher ..
iPhone 12 Pro Max iOS 14.4 qr_code_scanner: ^0.3.1
- Green dot notification does not disappear regardless of dispose() or pause().
- Same issue for qr_code_scanner: ^0.3.0.
Right . Initially I still thought that the error occurred because of the low version of the library and the features haven't been updated and the bug fixes I tried it with the latest version of the library and it doesn't seem to be solved .. Some users using Android devices and Apple devices with low version will not notice any obvious difference other than that their device is very hot and very battery intensive. But for users using iOS 14.0 and above, it seems that they are very noticeable by the green dot. One of them also responded that our app is doing with them, is it sneaking or doing something that affects privacy.?
Hey @leanhro2812 have you tried my code?
I tried your code on a sample app and it works with no problem with my iPhone XS with iOS 14.2.
I just tested your code on an iPad Air 2 running iOS 14.4 and i can confirm the green dot is still showing after navigating back to the first page.
The problem is that when you call controller.dispose()
it only closes the data stream but it doesn't pause the camera view. I'm gonna implement a way that completely removes the QRView. For now you can call controller?.pauseCamera
in your dispose override like so:
@override
void dispose() {
controller?.pauseCamera();
controller?.dispose();
super.dispose();
}
Very strange, on my iPhone the "green dot" disappear after 3/4 secs. I will try today with an iPad mini
Please try with version 0.3.2.
Thanks! Working good on v0.3.2 / iPhone 12 Pro Max / iOS14.4!
I say that issue is closed, but only to keep an history of the problem I tried the same code with qr_code_scanner 0.3.0
on a iPhone 8 and the camera is not disposed. On my iPhone XS it is disposed with no problem.
Anyway I will try with the new version
With version 0.5.2 I am still facing the issue of the green dot even I am disposing of controller as well as pausing the controller.
This is still reproducible in version qr_code_scanner: ^1.0.0
. Battery is draining really fast and the widget is used properly.
Describe the bug In the example QRViewExample is one page When I got to this page to run the code scan and Pop() to leave. Everything is still normal until iOS develops a feature that allows to tell whether the camera is still working or not in: Green dot notification light is always visible after accessing camera (IOS 14) Looks like the camera still works even though it left QRViewExample
Device: