Building the Flutter 💙 Barcode Scanner app

For a project, I need a barcode scanning plugin, to keep track of stocks of items with barcodes. Fortunately, theres a recent null safety compatible plugin for that so it should be good for Flutter 2.0 (There are a number of other barcode plugins but this one seems recent and it is for iOS and Android which is a requirement. Lets give it a try!

My project needs to be able to scan an inventory of items with barcodes and save them to a database. Optionally it could look up the description of the item from a source database or service. Then it needs to make that inventory available for use by other services such as a web site. This seems like something Flutter, and Firebase ought to be able to do.

You can find and use packages to build Dart and Flutter apps at which is where flutter_barcode_scanner: ^2.0.0 is to be found.

TL:DR — It 'just works' with Flutter 2.x so it will be good for the project.

Fork the project in Github, just in case we need to make changes to it. Then clone the project — Step by Step instructions

  1. Clone the fork of the repository,
    $ cd Projects/
    $ git clone This email address is being protected from spambots. You need JavaScript enabled to view it.:ezone-dev/flutter_barcode_scanner.git
    Cloning into 'flutter_barcode_scanner'...
    The authenticity of host ' (' can't be established.
    RSA key fingerprint is SHA256:jljg686y7687ygg8787iyg87687687hg87ggfgfdjg.
    Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
    Warning: Permanently added ',' (RSA) to the list of known hosts.
    remote: Enumerating objects: 1331, done.
    remote: Counting objects: 100% (142/142), done.
    remote: Compressing objects: 100% (93/93), done.
    remote: Total 1331 (delta 50), reused 88 (delta 29), pack-reused 1189
    Receiving objects: 100% (1331/1331), 516.24 KiB | 1.70 MiB/s, done.
    Resolving deltas: 100% (724/724), done.
    $ cd flutter_barcode_scanner/
  2. open the project in Android Studio, open pubspec.yaml and click on Packages get. To run on a connected Android device click 'Run'.

It built and runs just fine on my Pixel 2XL. On first scan it asks for camera permission, and then presents a simple scanning UI with a barcode overlay on the camera. As soon as the barcode on my soup can came into view it recorded the scan result on the page and output it to the Android Studio console. Looks very professional. Works and works quickly. Excellent.

Heres the screenshot of Android Studio running the downloaded code.

I/flutter (31686): 5000157062697

Looking it up, I can see it is indeed findable on a public lookup site with an API.

Now to try it out on iOS, and then integrate it to the requirements of the project.