flutter_web_qrcode_scanner 1.1.1 copy "flutter_web_qrcode_scanner: ^1.1.1" to clipboard
flutter_web_qrcode_scanner: ^1.1.1 copied to clipboard

Platformweb

Camera-based QR code scanning for Flutter-Web, The package makes use of the jsQR.js library to gain native access to the camera and scan QR codes

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_web_qrcode_scanner/flutter_web_qrcode_scanner.dart';
import 'package:flutter_web_qrcode_scanner_example/full_example.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: "Plugin Example",
      home: Scaffold(
        body: FullExample(),
      ),
    );
  }
}

class AutoScanExample extends StatefulWidget {
  const AutoScanExample({Key? key}) : super(key: key);

  @override
  State<AutoScanExample> createState() => _AutoScanExampleState();
}

class _AutoScanExampleState extends State<AutoScanExample> {
  String? _data;

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        _data == null
            ? Container()
            : Center(
                child: Text(
                  _data!,
                  style: const TextStyle(fontSize: 18, color: Colors.green),
                  textAlign: TextAlign.center,
                ),
              ),
        FlutterWebQrcodeScanner(
          cameraDirection: CameraDirection.back,
          onGetResult: (result) {
            setState(() {
              _data = result;
            });
          },
          stopOnFirstResult: true,
          width: MediaQuery.of(context).size.width * 0.8,
          height: MediaQuery.of(context).size.height * 0.8,
          onError: (error) {
            // print(error.message)
          },
          onPermissionDeniedError: () {
            //show alert dialog or something
          },
        ),
      ],
    );
  }
}
4
likes
140
pub points
80%
popularity

Publisher

unverified uploader

Camera-based QR code scanning for Flutter-Web, The package makes use of the jsQR.js library to gain native access to the camera and scan QR codes

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, flutter_web_plugins

More

Packages that depend on flutter_web_qrcode_scanner