CODEX

Exporting QR Codes in Flutter

Alisa "Foxicorn" Nekrasova
CodeX

--

QR codes are an easy way to exchange small amounts of data between smartphones (data reader) and any media (data provider). They are easy to generate and to scan, you can customize them, add logos, change colors, and make them “yours”.

Photo by Albert Hu on Unsplash

Two smartphones with Flutter apps can easily generate and scan QR codes, but generating QR codes for export is a little bit trickier.

Scanning QR codes with Flutter

Let’s start with scanning. Any iOS or Android device with a camera can scan and decode QR codes. As an example, we’ll use the flutter_qr_bar_scanner.

It provides a widget showing the camera feed — QRBarScannerCamera. You see what you scan and you get a callback when the code is recognized:

QRBarScannerCamera(
onError: (context, error) => Text(
error.toString(),
style: TextStyle(color: Colors.red),
),
qrCodeCallback: (code) {
_qrCallback(code);
},
)

The example above is from the official page of the scanner library.

Showing QR codes with Flutter

Showing QR codes on the screen is even easier. The library qr_flutter includes a widget, which can show any QR code with only 3 lines of code:

QrImage(
data…

--

--

Alisa "Foxicorn" Nekrasova
CodeX
Writer for

Game and software developer with more than 17 years of experience. Freelancer, writer, author of the book “Swift Recipes for iOS Developers”.