camcode 1.0.5 copy "camcode: ^1.0.5" to clipboard
camcode: ^1.0.5 copied to clipboard

outdated

A camera barcode scanner for Flutter Web using your favorite Javascript library

example/lib/main.dart

import 'package:camcode/cam_code_scanner.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      routes: {
        '/': (context) => MyApp(),
      },
      initialRoute: '/',
    ),
  );
}

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

class _MyAppState extends State<MyApp> {
  String barcodeValue = 'Press button to scan a barcode';

  @override
  Widget build(BuildContext context) {
    barcodeValue = ModalRoute.of(context).settings.arguments ??
        'Press button to scan a barcode';
    return MaterialApp(
      home: Scaffold(
        floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
        floatingActionButton: FloatingActionButton(
          child: Icon(Icons.scanner),
          onPressed: () => openScanner(context),
        ),
        appBar: AppBar(
          title: const Text('CamCode example app'),
        ),
        body: Center(
          child: Text(barcodeValue),
        ),
      ),
    );
  }

  void openScanner(BuildContext context) {
    showDialog(
      context: context,
      builder: (context) => CamCodeScanner(
        width: MediaQuery.of(context).size.width,
        height: MediaQuery.of(context).size.height,
        refreshDelayMillis: 800,
        onBarcodeResult: (barcode) {
          Navigator.of(context).pushNamed('/', arguments: barcode);
        },
      ),
    );
  }
}
41
likes
40
pub points
70%
popularity

Publisher

verified publishermobile-tools.dev

A camera barcode scanner for Flutter Web using your favorite Javascript library

Homepage
Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, flutter_web_plugins, js

More

Packages that depend on camcode