rfid 0.0.3 copy "rfid: ^0.0.3" to clipboard
rfid: ^0.0.3 copied to clipboard

outdated

RFID scanner plugin for integration in flutter applications. Package currently supports IOS platforms

example/lib/main.dart

import 'package:flutter/material.dart';

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

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: const MyHomePage(title: 'Test'),
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  bool _connectionResult = false;
  String? _connectedDevices;
  final _rfidpluginPlugin = RfidPlugin();

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

  void scanBarCode() async {
    await _rfidpluginPlugin.scanBarCode();
  }

  void _getBatteryLevel() async {
    try {
      await _rfidpluginPlugin.connectDevice();
      final bool connectionResult =
          await _rfidpluginPlugin.getDeviceConnectionStatus();

      final connectedDevices = await _rfidpluginPlugin.getAvailableDevices();

      setState(() {
        _connectionResult = connectionResult;
        _connectedDevices = connectedDevices.length.toString();
      });
    } on PlatformException catch (_) {
      setState(() {});
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'Connection Status ${_connectionResult.toString()}',
            ),
            Text(
              'Connected Devices ${_connectedDevices ?? 'No Devices Connected'}',
            ),
            IconButton(onPressed: scanBarCode, icon: const Icon(Icons.scanner)),
          ],
        ),
      ),
    );
  }
}
6
likes
0
points
45
downloads

Publisher

unverified uploader

Weekly Downloads

RFID scanner plugin for integration in flutter applications. Package currently supports IOS platforms

License

unknown (license)

Dependencies

flutter, json_annotation, plugin_platform_interface

More

Packages that depend on rfid

Packages that implement rfid