Barcode Scanner in Flutter

Barcode Scanner in Flutter

aseemwangoo No Comment
Flutter

Noblest pleasure is the joy of understanding…

Scanning barcodes

Going through variety of articles on internet, I struck upon the common use case of scanning/reading BarCodes..I always wanted to try this in Android, but always procrastinated, not until now…..

Barcode Scanner App

Barcode Scanner App

Searching through the flutter packages until I found barcode_scan

Let’s Begin

Add dependency

Add dependency

Add the dependency of barcode_scan : “0.0.4” in pubspec.yaml.

Next, add the following line in the Android Manifest of your app

<activity android:name="com.apptreesoftware.barcodescan.BarcodeScannerActivity"/>

Activity added in Android Manifest.xml

Activity added in Android Manifest.xml

When, you click on Capture Image button, scanning of barcode takes initialization….

It asks you for accessing the Camera permission. If denied, then response is returned on the UI, with

Error if not given permission…

Error if not given permission…

If given permission, it starts scanning the image with barcode and if found returns the number onto the screen…

Barcode scanned….

Barcode scanned….

Code snippet for scanning barcode :

Scanning barcode..

Scanning barcode..

Video demonstration :

Find the complete program at

https://github.com/AseemWangoo/flutter_programs/blob/master/barcode.dart

P.S………………………………

Leave a Reply