Closed maxmeng93 closed 1 month ago
You have to test using a real device, this is working as intended.
The iOS Simulator does not provide a "real" camera to provide images with, so mobile_scanner
would never work on it.
The Android Emulator does provide a "fake" camera view, but unless that fake view provides an image with a barcode, you can't test using that either.
@navaronbracke I tested the example barcode_scanner_controller.dart in mobile_scanner@5.0.0-beta.3 on my iPhone. When I first entered the page, it showed a black screen without rendering the camera view on the page, but it could scan correctly. However, when I clicked the start button at this time, the page would throw an error.
When I commented out unawaited(controller.start()); in initState(), and then clicked the start button, everything became normal.
That seems to be an oversight in the sample indeed. Since we have a manual "start" button, starting the controller in initState() defeats the purpose of said sample. I wonder why it only causes an issue on iOS, though? (I have been using that exact sample to test things out on Android / MacOS and web; but I didn't have an iOS device to test things on for a while)
I'll fix up the sample and test with an iOS device.
I used the official demo provided, but it does not work on the iOS simulator, it shows a black screen.