Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scanner Crash while Opening #84

Open
ravi-uleeco opened this issue Jan 12, 2024 · 4 comments
Open

Scanner Crash while Opening #84

ravi-uleeco opened this issue Jan 12, 2024 · 4 comments
Assignees

Comments

@ravi-uleeco
Copy link

ravi-uleeco commented Jan 12, 2024

Screenshot_20240112_120649

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,
),
);
}
}
`

@rvndsngwn
Copy link
Member

rvndsngwn commented Jan 12, 2024

Hi @ravi-uleeco Thanks for creating an issue.

can you share your code with 3 back ticks for easy to read you code.

it's best to use 3 back ticks with multi-line code. See https://www.markdownguide.org/extended-syntax/#syntax-highlighting

It would also be helpful if you shared console logs.

Device android version no:
package version:

@rvndsngwn rvndsngwn self-assigned this Jan 12, 2024
@ravi-uleeco
Copy link
Author

Can you please run the above code in Flutter you will get the idea bro. Don't have time to do this "share your code with 3 back ticks for easy to read you code".

Device Name: Samsung M-315F
Device Version: Android 12
Package Details:- Flutter 3.13.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 367f9ea16b (4 months ago) • 2023-09-12 23:27:53 -0500
Engine • revision 9064459a8b
Tools • Dart 3.1.2 • DevTools 2.25.0

@rvndsngwn
Copy link
Member

Hi @ravi-uleeco,
The latest version of this package has been released: ai_barcode_scanner: ^3.4.3.
Let me know if you are still facing this issue.

@JBtronic
Copy link

Add controller.stop(); on onDetect: (capture) {} & also try using canPop: false or true.
I don't know what is your use case. After detection, you are navigating push or pop, you know better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants