![Screenshot_20240112_120649](https://private-user-images.githubusercontent.com/135975935/296149435-82c6a351-66bc-4d75-b90d-cd0cc4dc5380.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTcyNzc4NzIsIm5iZiI6MTcxNzI3NzU3MiwicGF0aCI6Ii8xMzU5NzU5MzUvMjk2MTQ5NDM1LTgyYzZhMzUxLTY2YmMtNGQ3NS1iOTBkLWNkMGNjNGRjNTM4MC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYwMVQyMTMyNTJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zZDFiODk5ZGE4YzIzMzU2ZDgwMmFmNTBmNWJlMTY5ODA4MDljNDNlYjExNTA2OWY5YjE0OTA4NjI3ODMxN2YzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.mmFc4XVoBiLLDYpi52_9Be45fgVmpkJGwiojXsnF8Us)
Sometimes, the app scanner crashes. Can you guide me if anything I'm doing wrong?
This is my code:
`import 'package:ai_barcode_scanner/ai_barcode_scanner.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class ScanBarcodePage extends GetView {
const ScanBarcodePage({super.key});
@OverRide
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: _buildBody(context),
);
}
Widget _buildBody(BuildContext context) {
return Stack(
children: [
_scanView(context),
SizedBox(
width: MediaQuery.of(context).size.width,
child: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: MediaQuery.of(context).size.height * 0.45,
),
const Text(
"Align barcode in frame to scan",
style: CTAppTextStyles.pageSmallTextStyle,
),
],
),
),
),
SafeArea(
child: Align(
alignment: Alignment.topCenter,
child: SizedBox(
height: 50,
child: Stack(
children: [
const Center(
child: Text(
"Scan Barcode",
style: TextStyle(color: CTColor.white),
),
),
IconButton(
onPressed: () {
Get.back();
},
icon: const Icon(
Icons.arrow_back_ios_new,
),
iconSize: 15,
),
],
),
),
),
)
],
);
}
Widget _scanView(BuildContext context) {
return AiBarcodeScanner(
onScan: (value) {
debugPrint("value: $value");
},
onDetect: (capture) {
final List barcodes = capture.barcodes;
for (final barcode in barcodes) {
debugPrint('Barcode found! ${barcode.rawValue}');
}
},
controller: MobileScannerController(
detectionSpeed: DetectionSpeed.noDuplicates,
),
bottomBar: Container(
height: 0,
width: Size.infinite.width,
color: Colors.transparent,
),
);
}
}
`