flutter_datalogic 1.0.6 copy "flutter_datalogic: ^1.0.6" to clipboard
flutter_datalogic: ^1.0.6 copied to clipboard

A Flutter package communicate with Datalogic scanners.

example/lib/main.dart

import 'dart:async';
import 'dart:io';

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

void main() => runApp(MaterialApp(home: const ExampleApp()));

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

  @override
  State<ExampleApp> createState() => _ExampleAppState();
}

class _ExampleAppState extends State<ExampleApp> {
  late FlutterDatalogic fdl;
  late StreamSubscription onSubscription;

  var scannerStatus = ScannerStatusType.IDLE;
  var scannedBarcode = 'Press Scan button on device';

  @override
  void initState() {
    initScanner();
    super.initState();
  }

  Future<void> initScanner() async {
    if (Platform.isAndroid) {
      fdl = FlutterDatalogic();
      onSubscription = fdl.onScannerInfo.listen((event) {
        setState(() {
          scannerStatus = event.status;
          scannedBarcode = event.data;
        });
      });
    }
  }

  @override
  void dispose() {
    onSubscription.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Datalogic demo')),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Text(
              'Status : ${scannerStatus.name}',
              textAlign: TextAlign.center,
            ),
            SizedBox(
              height: 16.0,
            ),
            Text(
              scannedBarcode,
              textAlign: TextAlign.center,
            ),
            // TextButton(onPressed: _scan, child: Text('Scan')),
          ],
        ),
      ),
    );
  }

// void _scan() {}
}

class ScanData {
  ScanData(this.scannerStatus, this.scannedBarcode);

  final ScannerStatusType scannerStatus;
  final String scannedBarcode;
}
2
likes
0
points
414
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package communicate with Datalogic scanners.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, freezed_annotation, freezed_result, json_annotation, uuid

More

Packages that depend on flutter_datalogic