flutter_barcode_scanner_sdk 0.1.1 copy "flutter_barcode_scanner_sdk: ^0.1.1" to clipboard
flutter_barcode_scanner_sdk: ^0.1.1 copied to clipboard

High-throughput barcode and QR scanner SDK for Flutter apps.

Flutter Barcode Scanner SDK #

pub package CI

High-throughput barcode and QR scanner SDK for Flutter apps.

The package provides two native scanning modes:

  • FlutterBarcodeScanner.scan(config) opens a full-screen scanner and returns one result.
  • FlutterBarcodeScannerView embeds the native scanner in a Flutter layout and emits results through a controller-friendly widget API.

Android uses CameraX with ML Kit Barcode Scanning. iOS uses AVFoundation. The iOS plugin supports Swift Package Manager and CocoaPods.

Contents #

Platform Support #

Platform Minimum Native engine
Android API 24 CameraX + ML Kit Barcode Scanning
iOS 15.0 AVFoundation metadata scanning
Flutter 3.44.0 AGP 9 / Gradle 9 Android plugin build
Dart 3.12.0 Sound null safety

Installation #

dependencies:
  flutter_barcode_scanner_sdk: ^0.1.0

Then run:

flutter pub get

Permissions #

Android #

The plugin declares android.permission.CAMERA. If your app has a custom manifest merge setup, confirm that the merged app manifest includes:

<uses-permission android:name="android.permission.CAMERA" />

iOS #

Add a camera usage description to ios/Runner/Info.plist:

<key>NSCameraUsageDescription</key>
<string>This app scans barcodes with the camera.</string>

Full-Screen Scanner #

final result = await FlutterBarcodeScanner.scan(
  const FlutterBarcodeScannerConfig(
    allowedFormats: FlutterBarcodeScannerFormats.common,
    strings: FlutterBarcodeScannerStrings(title: 'Scan ticket'),
  ),
);

if (result?.isBarcode == true) {
  debugPrint('Scanned ${result!.format.name}: ${result.rawValue}');
}

Embedded Scanner #

final controller = FlutterBarcodeScannerController();

FlutterBarcodeScannerView(
  controller: controller,
  config: const FlutterBarcodeScannerConfig(
    allowedFormats: FlutterBarcodeScannerFormats.qrOnly,
    scanWindow: FlutterBarcodeScannerScanWindow(
      enabled: true,
      widthFactor: 0.58,
      heightFactor: 0.58,
    ),
  ),
  widgetConfig: const FlutterBarcodeScannerWidgetConfig(
    autoRequestCameraPermission: true,
    freezePreviewWhenPaused: true,
    showPauseResumeButton: true,
  ),
  autoStart: true,
  autoPauseOnScan: true,
  onScan: (result) {
    if (result.isBarcode) {
      // Process the result, then resume when ready for another scan.
      controller.resumeDetection();
    }
  },
);

Controller actions:

  • startCamera() and stopCamera()
  • pauseDetection() and resumeDetection()
  • toggleFlash([bool? enabled])
  • switchCamera([BarcodeCameraLens? lens])
  • updateConfig(config)
  • dispose()

Format Presets #

Use FlutterBarcodeScannerFormats for common format groups:

const FlutterBarcodeScannerConfig(
  allowedFormats: FlutterBarcodeScannerFormats.twoDimensional,
);

Available presets include all, common, oneDimensional, twoDimensional, and qrOnly.

Example App #

The bundled example app demonstrates:

  • Full-screen and embedded scanner modes
  • Scan-window and whole-preview detection
  • RTL/LTR strings
  • Flash and camera switching
  • Auto-start, auto-pause, pause/resume, and freeze-preview behavior
  • App bar, status bar, overlay, and format preset options

Run it with:

cd example
flutter run

API Reference #

See API_REFERENCE.md for tables covering all public configuration fields, defaults, result fields, controller methods, and supported barcode formats.

Generated Dart API docs are available on pub.dev after publication.

Troubleshooting #

Symptom Check
Permission screen does not appear Confirm camera permission is in the Android manifest or NSCameraUsageDescription is in Info.plist.
Embedded scanner stays black Ensure the widget has non-zero size and the controller has not been disposed.
No barcode is detected Try scanWindow.enabled = false, verify lighting/focus, and restrict allowedFormats only when the expected format is known.
iOS build integration issue Use Flutter 3.44 or newer and keep Swift Package Manager enabled; CocoaPods remains supported through the podspec.

License #

BSD 3. See LICENSE.