Cover image by Wilfried Pohnke from Pixabay
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 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.
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 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:
// 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);
You can also customize a bit the capturing screen, matching the app look and feel:
// 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,
);
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!
Top comments (2)
AMAZING!!!
Hi! Your package seems great, any updates on how the web support is coming?