fluttervisionsdkplugin 0.0.3 copy "fluttervisionsdkplugin: ^0.0.3" to clipboard
fluttervisionsdkplugin: ^0.0.3 copied to clipboard

A Flutter plugin package for integrating the Flutter Vision SDK into your Flutter application for scanning Barcodes and QrCodes

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  void _onScanError(String errorMessage) {
    print('Scan Error: $errorMessage');
  }

// pr
  String scannedCode = '';
  String detectedType = '';
  bool isManualCaptureMode = false;
  bool shouldDisplayFocusImage = false;

  List<String> receivedCodes = [];

  void updateReceivedCodes(List<String> codes) {
    setState(() {
      receivedCodes = codes;
    });
  }

  void updateCaptureMode(bool isManual) {
    setState(() {
      isManualCaptureMode = isManual;
    });
  }

  void updateScannedCode(String code) {
    setState(() {
      scannedCode = code;
    });
  }

  void onDetected(String type) {
    setState(() {
      detectedType = type;
    });
  }

  void _onCodesReceived(List<String> codes) {
    updateReceivedCodes(codes);

    if (codes.isNotEmpty) {
      updateScannedCode(codes.first);
    } else {
      updateScannedCode('');
    }
  }

  void _onDetectionResult(
      bool textDetected, bool barCodeDetected, bool qrCodeDetected) {
    print('Text Detected: $textDetected');
    print('Barcode Detected: $barCodeDetected');
    print('QR Code Detected: $qrCodeDetected');
  }

  void _onOCRImagesReceived(Map<String, dynamic> scanResult) {
    print(scanResult);
  }

  void _changeCaptureMode(String mode) {
    print('Changing Capture Mode to: $mode');
  }

  void _changeScanMode(String mode) {
    print('Changing Scan Mode to: $mode');
  }

  void _capture() {
    print('Capturing Photo');
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: Stack(
          children: [
            NativeViewWidget(
                onScanError: _onScanError,
                onCodesReceived: _onCodesReceived,
                onDetectionResult: _onDetectionResult,
                onOCRImagesReceived: _onOCRImagesReceived,
                shouldDisplayFocusImage: true,
                shouldScanInFocusImageRect: true,
                onDetected: onDetected,
                isTextIndicationOn: true,
                isBarCodeOrQRCodeIndicationOn: true,
                selectionTintColor: 'white',
                imageTintColor: 'white',
                codeDetectionConfidence: 0.5,
                sessionPreset: 'high',
                nthFrameToProcess: 10,
                captureMode: 0,
                captureType: 0,
                scanMode: 0,
                focusImage: '',
                focusImageRect: const {
                  'x': 0,
                  'y': 0,
                  'height': 0,
                  'width': 0,
                }),
            Positioned(
              left: 0,
              right: 0,
              bottom: 0,
              child: Padding(
                padding: const EdgeInsets.all(16.0),
                child: Container(
                  alignment: Alignment.bottomCenter,
                  width: double.infinity,
                  color: Colors.white,
                  padding: const EdgeInsets.all(16),
                  child: Column(
                    children: [
                      Text(
                        'Detected Type: $detectedType',
                        style:
                            const TextStyle(color: Colors.black, fontSize: 16),
                      ),
                      Text(
                        'Scanned Code: $scannedCode',
                        style:
                            const TextStyle(color: Colors.black, fontSize: 16),
                      ),
                      ElevatedButton(
                        onPressed: () {
                          const NativeViewWidget()
                              .onPressChangeCaptureMode('auto');
                        },
                        child: const Text('Change Capture Mode to Auto'),
                      ),
                      ElevatedButton(
                        onPressed: () {
                          const NativeViewWidget()
                              .onPressChangeCaptureMode('manual');
                          updateCaptureMode(true);
                        },
                        child: const Text('Change Capture Mode to Manual'),
                      ),
                      ElevatedButton(
                        onPressed: () {
                          const NativeViewWidget()
                              .onPressChangeScanMode('qrcode');
                        },
                        child: const Text('Change Scan Mode to QR Code'),
                      ),
                      ElevatedButton(
                        onPressed: () {
                          const NativeViewWidget()
                              .onPressChangeScanMode('barcode');
                        },
                        child: const Text('Change Scan Mode to Barcode'),
                      ),
                      ElevatedButton(
                        onPressed: () {
                          const NativeViewWidget().onPressChangeScanMode('ocr');
                        },
                        child: const Text('Change Scan Mode to OCR'),
                      ),
                      if (isManualCaptureMode)
                        ElevatedButton(
                          onPressed: () {
                            const NativeViewWidget().onPressCapture();
                          },
                          child: const Text('Capture Photo'),
                        ),
                    ],
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
2
likes
0
points
891
downloads

Publisher

verified publisherpackagex.io

Weekly Downloads

A Flutter plugin package for integrating the Flutter Vision SDK into your Flutter application for scanning Barcodes and QrCodes

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface

More

Packages that depend on fluttervisionsdkplugin