qr_flutter 3.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 99

QR.Flutter is a Flutter library for simple and fast QR code rendering via a Widget or custom painter.

Features #

  • Built on QR - Dart
  • Automatic QR code version/type detection or manual entry
  • Supports QR code versions 1 - 40
  • Error correction / redundancy
  • Configurable output size, padding, background and foreground colors
  • Supports image overlays
  • Export to image data to save to file or use in memory
  • No internet connection required

Installing #

You should add the following to your pubspec.yaml file:

  qr_flutter: ^3.1.0

Note: If you're using the Flutter master channel, if you encounter build issues, or want to try the latest and greatest then you should use the master branch and not a specific release version. To do so, use the following configuration in your pubspec.yaml:

      url: git://github.com/lukef/qr.flutter.git

Keep in mind the master branch could be unstable.

After adding the dependency to your pubspec.yaml you can run: flutter packages get or update your packages using your IDE.

Getting started #

To start, import the dependency in your code:

import 'package:qr_flutter/qr_flutter.dart';

Next, to render a basic QR code you can use the following code (or something like it):

  data: "1234567890",
  version: QrVersions.auto,
  size: 200.0,

Depending on your data requirements you may want to tweak the QR code output. The following options are available:

versionintQrVersions.auto or a value between 1 and 40. See http://www.qrcode.com/en/about/version.html for limitations and details.
errorCorrectionLevelintA value defined on QrErrorCorrectLevel. e.g.: QrErrorCorrectLevel.L.
sizedoubleThe (square) size of the image. If not given, will auto size using shortest size constraint.
paddingEdgeInsetsPadding surrounding the QR code data.
backgroundColorColorThe background color (default is none).
foregroundColorColorThe foreground color (default is black).
gaplessboolAdds an extra pixel in size to prevent gaps (default is true).
errorStateBuilderQrErrorBuilderAllows you to show an error state Widget in the event there is an error rendering the QR code (e.g.: version is too low, input is too long, etc).
constrainErrorBoundsboolIf true, the error Widget will be constrained to the square that the QR code was going to be drawn in. If false, the error state Widget will grow/shrink to whatever size it needs.
embeddedImageImageProviderAn ImageProvider that defines an image to be overlaid in the center of the QR code.
embeddedImageStyleQrEmbeddedImageStyleProperties to style the embedded image.
embeddedImageEmitsErrorboolIf true, any failure to load the embedded image will trigger the errorStateBuilder or render an empty Container. If false, the QR code will be rendered and the embedded image will be ignored.

Examples #

There is a simple, working, example Flutter app in the /example directory. You can use it to play with all the options.

Also, the following examples give you a quick overview on how to use the library.

A basic QR code will look something like:

  data: 'This is a simple QR code',
  version: QrVersions.auto,
  size: 320,
  gapless: false,

A QR code with an image (from your application's assets) will look like:

  data: 'This QR code has an embedded image as well',
  version: QrVersions.auto,
  size: 320,
  gapless: false,
  embeddedImage: AssetImage('assets/images/my_embedded_image.png'),
  embeddedImageStyle: QrEmbeddedImageStyle(
    size: Size(80, 80),

To show an error state in the event that the QR code can't be validated:

  data: 'This QR code will show the error state instead',
  version: 1,
  size: 320,
  gapless: false,
  errorStateBuilder: (cxt, err) {
    return Container(
      child: Center(
        child: Text(
          "Uh oh! Something went wrong...",
          textAlign: TextAlign.center,


Has it been tested in production? Can I use it in production? #

Yep! It's stable and ready to rock. It's currently in use in quite a few production applications including:

Outro #

Credits #

Thanks to Kevin Moore for his awesome QR - Dart library. It's the core of this library.

For author/contributor information, see the AUTHORS file.

License #

QR.Flutter is released under a modified MIT license. See LICENSE for details.

3.2.0 #

  • Fix issue where finder patterns don't render correctly with the painter
  • Small fixes + optimizations

3.1.0 #

  • Fix issue with emptyColor rendering.
  • Fix a bug related to placeholder image loading.
  • Bump to Flutter 1.7+. Flutter API changes have necessitated a bump. Sorry.

3.0.1 #

  • Added an example.

3.0.0 #

  • Use QrVersions.auto and let the library pick the appropriate version for you.
  • Add an image that will be overlaid in the centre of the widget. You can specify the image size but not position.
  • QrImage.onError has been removed. It was horribly broken so we decided to not deprecate it and just remove it totally.
  • QrImage.errorStateBuilder introduced to allow you to display an in-line Widget when an error (such as data too long) occurs. By default the error state Widget will be constrained to the QRImage bounds (aka a Square) but you can use the constrainErrorBounds property to prevent that.
  • A bunch of bug fixes you can look at in the source code.

2.1.0 #

  • The gapless option is now true by default.
  • Allow assigning Key values to QrImage widgets.
  • Update qr.dart dependency.
  • qr.dart is now exported so you don't need a second import.

2.0.0 #

  • Flutter 1.2.1 compatibility

2.0.0-dev.1 #

1.1.6 #

  • Adds analyzer configuration
  • Fixes linting issues
  • Migrate to Dart 2.x friendly syntax
  • Tidy some initialization logic / code
  • Bump copyright

1.1.5 #

  • Add image data export functions (see test/painter_tests.dart for an example)

1.1.4 #

  • Add gapless toggle

1.1.3 #

  • Lower min sdk version to cater to some older versions of Flutter

1.1.2 #

  • The QrImage widget will now autosize if no size has been defined (thanks @romkor!)
  • Requires Dart 2 (as so does Flutter)
  • Dart 2 pubspec compatability changes

1.1.1 #

  • Fixes and issue where the QR image won't get repainted even though the data has changed

1.1.0 #

  • Update to 1.0 release of the dart qr library

1.0.0 #

  • Initial release


 * QR.Flutter
 * Copyright (c) 2019 the QR.Flutter authors.
 * See LICENSE for distribution and usage details.

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'main_screen.dart';

void main() => runApp(ExampleApp());

/// The example application class
class ExampleApp extends StatelessWidget {
  // This widget is the root of your application.
  Widget build(BuildContext context) {
      statusBarColor: Colors.white,
      statusBarIconBrightness: Brightness.dark,
      systemNavigationBarColor: Colors.white,
      systemNavigationBarIconBrightness: Brightness.dark,
    return MaterialApp(
      title: 'QR.Flutter',
      theme: ThemeData.light(),
      debugShowCheckedModeBanner: false,
      home: MainScreen(),

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  qr_flutter: ^3.2.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:qr_flutter/qr_flutter.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
flutter 0.0.0
qr ^1.2.0 1.2.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
test ^1.6.0