flutter_imin_lark_scanner 1.0.1 copy "flutter_imin_lark_scanner: ^1.0.1" to clipboard
flutter_imin_lark_scanner: ^1.0.1 copied to clipboard

Flutter plugin for the built-in barcode scanner on iMIN Lark Android devices.

example/lib/main.dart

import 'dart:async';

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

void main() => runApp(const MyApp());

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(debugShowCheckedModeBanner: false, home: ScannerPage());
  }
}

class ScannerPage extends StatefulWidget {
  @override
  State<ScannerPage> createState() => _ScannerPageState();
}

class _ScannerPageState extends State<ScannerPage> {
  String? _scannedData;
  StreamSubscription<String>? _scanSubscription;

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

    final scanner = FlutterIminLarkScanner.instance;
    unawaited(scanner.prepare());
    _scanSubscription = scanner.barcodes.listen(
      (value) {
        if (!mounted) return;
        setState(() => _scannedData = value);
      },
      onError: (error) {
        debugPrint('Scan stream error: $error');
      },
    );
  }

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('IMIN Scanner')),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.all(24),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Icon(
                Icons.qr_code_scanner,
                size: 64,
                color: Theme.of(context).colorScheme.primary,
              ),
              const SizedBox(height: 24),
              Text(
                _scannedData ?? 'No scan yet',
                textAlign: TextAlign.center,
                style: Theme.of(context).textTheme.titleMedium?.copyWith(
                  color: _scannedData == null
                      ? Theme.of(context).colorScheme.onSurfaceVariant
                      : null,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
150
points
181
downloads

Documentation

API reference

Publisher

verified publisherpatel-apps.com

Weekly Downloads

Flutter plugin for the built-in barcode scanner on iMIN Lark Android devices.

Repository
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_imin_lark_scanner

Packages that implement flutter_imin_lark_scanner