Closed victorLyw closed 1 year ago
This is also a problem in iOS. Are there any workarounds to support landscape mode?
We have the same issue with iOS. Any idea of a temporal alternative way to use landscape mode?
@Cosmo2357 You can try using qr_code_scanner
@victorLyw Thanx vicorLyw :D Actually, I'm trying to switch from qr_code_scanner since mobile_scanner is pretty fast and steady. it seems native_device_orientation works. I'm not sure though... [https://github.com/juliansteenbakker/mobile_scanner/discussions/17(https://github.com/juliansteenbakker/mobile_scanner/discussions/17)
We use mobile_scannner, and wrap it in a Transform.rotate
widget.
Then, using a simple function we can make the rotation conditional:
bool isLandscape(BuildContext context) => orientation(context) == Orientation.landscape ? true : false;
It is not ideal, as it will not support full screen in landscape mode (a portrait image will be shown with "letterboxing" on each side), but it does enable us to use mobile_scanner.
qr_code_scanner is not maintained and have some issues with Flutter 3
@eivihnd Thanx elvihnd! That's an interesting way. works without external package?maybe...? I have no idea what would happen if I won't use full-screen mode in our app though. maybe aspect ratio will change or something like that?
Yep. qr_code_scanner is not maintained. that's my concern too.
Yes, it works without any external packages, as Orientation
is part of Flutter's MediaQuery
.
If you have issues with Aspect Ratio, wrapping it in a AspectRatio
widget might be a solution. Worth a try...
@eivihnd Thanks eivihnd! That’s great! But unfortunately, the camera gets whited out on my real iOS device if I wrap Mobile_Scanner widget with Transform.rotate widget.
on the iPhone simulator, the camera appears working so I guess It's my old iPhone-specific issue.
I'm still using iPhone 6. in case someone gets stuck with the same issue on an antique device.
I'll try again when I get a new phone! 😄
Thanks
Hmm, strange. We use it on different iPads, and it works without any problems. Does issue #175 relate to your problem?
@victorLyw Maybe not. The camera is not scanning either 😞 I simply used flutter run
How are you handling the key
supplied to the MobileScanner? Have you tried supplying a GlobalKey
, and seen what happens?
MobileScanner( key: GlobalKey(debugLabel: "mobile-scanner-key"), controller: widget._controller, onDetect: onQrDetected, ),
@eivihnd I'm actually new to flutter... Maybe I should learn bout key at first.
My code is nothing special. just like an example code of the package. and I warped it with Transform.rotate
and I wrote key: GlobalKey(debugLabel: "mobile-scanner-key"),
as you mentioned. still white screen...
if I remove Transform.rotate
it works.
MobileScannerController cameraController = MobileScannerController();
…..
Transform.rotate(
angle: 60,
child: MobileScanner(
key: GlobalKey(debugLabel: "mobile-scanner-key"),
allowDuplicates: true,
controller: cameraController,
onDetect: (barcode, args) {
if (barcode.rawValue == null) {
debugPrint('Failed to scan Barcode');
} else {
final String code = barcode.rawValue;
_myFunc(code);
}
}
),
),
@Cosmo2357 Your code works on my iPad. Have you tried with a different device?
@eivihnd Sorry for the late reply. I don't have any other iOS mobile devices. So, I asked my friends to check it with their devices.
Btw It seems that the author of mobile_scanner is trying to implement the rotation function. How to handle device orientation changes #17 Is it possible to detect landscape left or landscape right too in your code without external packages?
I appreciate your help :D
@eivihnd My friend had the same issue with my code on his iPad. weird... About implementing "right left detection" part, Maybe we have to use method channel or event channel , I guess 🤔
It seems like more people have a similar issue, ref #200. If I find time, I will test it on my iPhone.
I'm closing this issue in favor of #17 in order to keep the issues section clean.
I use the Android phone in landscape mode and start QR code scanning, but the MobileScanner view cannot achieve the expected effect.