admin管理员组文章数量:1392007
I am using simple_barcode_scanner
On iOS, the barcode scanner does not close immediately after detecting a barcode. Instead, it only closes when the camera is moved away from the barcode. However, on Android, the scanner behaves correctly, closing as soon as a barcode is detected.
Expected Behavior: The scanner should automatically close as soon as a barcode is scanned, similar to Android behavior.
Actual Behavior: On Android: The scanner correctly detects a barcode and closes immediately. On iOS: The scanner remains open and only closes when the camera is moved away from the barcode.
Steps to Reproduce: Create a new Flutter project and add simple_barcode_scanner.
Implement the scanner using the following code:
scan() async {
String? barcodeScanRes = await SimpleBarcodeScanner.scanBarcode(
context,
barcodeAppBar: const BarcodeAppBar(
appBarTitle: 'Scan',
centerTitle: false,
enableBackButton: true,
backButtonIcon: Icon(Icons.arrow_back_ios),
),
isShowFlashIcon: true,
delayMillis: 2000,
cameraFace: CameraFace.back,
lineColor: "#E81A5E",
);
}
Run the app on both Android and iOS devices. Scan a barcode.
Observe the behavior: On Android: Scanner detects and closes immediately. On iOS: Scanner remains open until the camera moves away from the barcode.
Flutter version:
[√] Flutter Channel stable, 3.29.1
I am using simple_barcode_scanner
On iOS, the barcode scanner does not close immediately after detecting a barcode. Instead, it only closes when the camera is moved away from the barcode. However, on Android, the scanner behaves correctly, closing as soon as a barcode is detected.
Expected Behavior: The scanner should automatically close as soon as a barcode is scanned, similar to Android behavior.
Actual Behavior: On Android: The scanner correctly detects a barcode and closes immediately. On iOS: The scanner remains open and only closes when the camera is moved away from the barcode.
Steps to Reproduce: Create a new Flutter project and add simple_barcode_scanner.
Implement the scanner using the following code:
scan() async {
String? barcodeScanRes = await SimpleBarcodeScanner.scanBarcode(
context,
barcodeAppBar: const BarcodeAppBar(
appBarTitle: 'Scan',
centerTitle: false,
enableBackButton: true,
backButtonIcon: Icon(Icons.arrow_back_ios),
),
isShowFlashIcon: true,
delayMillis: 2000,
cameraFace: CameraFace.back,
lineColor: "#E81A5E",
);
}
Run the app on both Android and iOS devices. Scan a barcode.
Observe the behavior: On Android: Scanner detects and closes immediately. On iOS: Scanner remains open until the camera moves away from the barcode.
Flutter version:
[√] Flutter Channel stable, 3.29.1
Share Improve this question edited Mar 12 at 6:20 king mort asked Mar 12 at 5:14 king mortking mort 1,47310 silver badges12 bronze badges1 Answer
Reset to default 0This is because the behavior of barcode scanners can vary between platforms due to differences in how camera and scanning APIs are implemented.
Try Below Solutions:
Implement a Workaround: As a temporary solution, you can programmatically close the scanner once a barcode is detected by modifying the package's source code or handling the state within your application.
Explore Alternative Packages: Consider using other barcode scanning packages that offer more consistent behavior across platforms. One such package is
mobile_scanner
, or similar to this.
版权声明:本文标题:Flutter simple_barcode_scanner Does Not Auto-Close After Scanning on iOS (Works on Android) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744769307a2624238.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论