mvbarcodescan 0.0.2 copy "mvbarcodescan: ^0.0.2" to clipboard
mvbarcodescan: ^0.0.2 copied to clipboard

outdated

A new Flutter plugin to scan barcode and qrcodes using Google Mobile vision & Apple AVFoundation

example/lib/main.dart

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

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

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  String _scannedBarCode = 'Unknown';

  @override
  void initState() {
    super.initState();
   // initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await Mvbarcodescan.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }


    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> scanBarCode() async {
    String barCode;
    try {
      barCode = await Mvbarcodescan.scan;
    } on PlatformException {
      barCode = '';
    }

    setState(() {
      _scannedBarCode = barCode;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            scanBarCode();
          },
          child: Icon(Icons.camera),
        ),
        appBar: AppBar(
          title: const Text('Barcode Scan Example'),
        ),
        body: Center(
          child: Text('Scanned Barcode : $_scannedBarCode\n'),
        ),
      ),
    );
  }
}
2
likes
0
pub points
5%
popularity

Publisher

verified publisherandroid-pratap.blogspot.com

A new Flutter plugin to scan barcode and qrcodes using Google Mobile vision & Apple AVFoundation

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on mvbarcodescan