scan_preview 0.0.1 copy "scan_preview: ^0.0.1" to clipboard
scan_preview: ^0.0.1 copied to clipboard

outdated

A flutter plugin for scan barcode.

scan_preview #

A new flutter plugin project.

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 _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    _requestPermission();
  }

  _requestPermission() async {
    await Permission.camera.request();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Scan barcode example'),
        ),
        body: Container(
          child: ScanPreviewWidget(
            onScanResult: (result) {
              setState(() {
                debugPrint('scan result: $result');
              });
            },
          ),
        ),
      ),
    );
  }
}

I use PermissionHandler to request camera permission

ios #

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

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

android #

do nothing

TODO #

  • ❌ ios to be tested

Warning #

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

7
likes
30
pub points
43%
popularity

Publisher

unverified uploader

A flutter plugin for scan barcode.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on scan_preview