Barras: A simple barcode/QR code reader package for Flutter
Tags: hacktoberfest, opensource, contributorswanted, flutter
Published: 2020-10-28 20:17:22

---
title: Barras: A simple barcode/QR code reader package for Flutter
published: true
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/anmwg0lz4fqsk5mzjk9a.jpg
tags: hacktoberfest, opensource, contributorswanted, flutter
---

###### Cover image by <a href="https://pixabay.com/users/wir_sind_klein-6630807/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3970681">Wilfried Pohnke</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=3970681">Pixabay</a>

There are plenty of great dart plugins that do the same thing: scan barcodes and QR codes. But what happens when you have a very specific requirement? Like: _"My app can't use Google Services!"_

### What is Barras

It means "bars" in Portuguese. But besides that, [Barras](https://github.com/deadblit/barras) is a QR code and barcode scanning library that uses ZXing and AVCaptureSession under the hood. It is simple to use and has a customizable capture screen.

You can find [Barras in pub.dev.](https://pub.dev/packages/barras)

Currently it only supports Android and iOS, and there are some known issues. But I'm planning to fix them, and add Flutter web support on it.

### Why another package?

I tested some barcode scanning packages that do not rely on Google Services (or ML Kit Vision API), and while they seem to work, there were some limitations, like requiring your app to support only Android 7 or newer. Other projects looked like they were abandoned.

A project that I'm working on required urgently to have a substitute solution that could run on Android 5 and newer. So only one of the plugins that I found could be used, but it required me to create the barcode capturing screen.

What if I create a customizable capturing screen for that plugin and let other people use it? At this point it is not the most refined solution out there: [Barras](https://github.com/deadblit/barras) is a package that introduces other transient dependencies on your project, but the big plan is to do everything inside Barras and implement the web support.

It is important to say that I see this as a great opportunity to contribute with open source. I've always used OSS operating systems, toolchains, libraries, but I feel that I never retributed properly. I believe that this package will be useful for people living in places that have restrictions on some Google products.


### How it looks like

It is simple as:

```dart
// Open the barcode reading page. Returned data will be null if
// Cancel button is pressed, or if user navigates back
final data = await Barras.scan(context);
```

![Default barcode capture page](https://github.com/deadblit/barras/raw/main/example/screenshots/Screenshot_20201022-034615.jpg)

You can also customize a bit the capturing screen, matching the app look and feel:

```dart
// Open the barcode reading page. Customize the appearance, changing the
// viewfinder color, size and blinking speed. Returned data will be null
// if Cancel button is pressed, or if user navigates back
final codigo = await Barras.scan(
  context,
  viewfinderHeight: 120,
  viewfinderWidth: 300,
  scrimColor: Color.fromRGBO(0, 128, 0, 0.5),
  borderColor: Colors.lightGreen,
  borderRadius: 24,
  borderStrokeWidth: 2,
  buttonColor: Colors.yellow,
  borderFlashDuration: 250,
  cancelButtonText: "Cancelar",
  successBeep: false,
);
```

![Página de captura customizada](https://github.com/deadblit/barras/raw/main/example/screenshots/Screenshot_20201026-181635.jpg)

### Feedback and contributions

I'm looking for feedback on Barras. It is in use in an app that is nearly finished, and the detection is fine for the app use cases. But I believe that there is room for improvement.

Any help and feedback is appreciated, please file an issue in our repo or send me a message!

{% github deadblit/barras no-readme %}