scan_preview 1.0.2 icon indicating copy to clipboard operation
scan_preview: ^1.0.2 copied to clipboard

A flutter plugin for scan barcode. This plugin is based on PlatformView.

scan_preview #

A QR code scanner flutter plugin project. Using PlatfromView to open native camera page scan qr code.

Installation #

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

  scan_preview: ^1.0.0

Getting Started #

android: barcodescanner ios: MTBBarcodeScanner

This plugin is based on PlatformView, which means you can customize the scanning UI freely. By the way, the framing UI is limited to the native API, and only a part of the attribute customization can be provided.

How to use #

class ScanPreviewPage extends StatefulWidget {
  _ScanPreviewPageState createState() => _ScanPreviewPageState();

class _ScanPreviewPageState extends State<ScanPreviewPage> {
  void initState() {

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Scan barcode example'),
        body: SizedBox(
          width: double.infinity,
          height: double.infinity,
          child: ScanPreviewWidget(
            onScanResult: (result) {
              debugPrint('scan result: $result');
              Navigator.pop(context, result);

About Permission : You should request the camear permission by yourself, I use PermissionHandler to request camera permission in this example.

ios #

You need to include the following Info.plist key in order to request camera access or the application will crash:

<string>Can we access your camera in order to scan barcodes?</string>

Important: Adding a boolean property to the Info.plist


android #

Use directly.


I am an android developer, there are still many features of ios that are not implemented.

If you are an ios developer, welcome to contribute your code.

  • ios to be tested
  • ios scan radar
  • read code from gallery

Warning #

On android device and in debug mode, the camera preview will stuck sometimes, but it did not happen in release mode.

pub points


unverified uploader

A flutter plugin for scan barcode. This plugin is based on PlatformView.

Repository (GitHub)


Icon for licenses.MIT (LICENSE)




Packages that depend on scan_preview