nfc_hce_reader 0.0.2 nfc_hce_reader: ^0.0.2 copied to clipboard
Flutter plugin for reading NDEF messages on Android and iOS phones. Currently it reads messages from Android phones emulating tags via HCE. This plugin was inspired by https://pub.dev/packages/nfc_in_ [...]
nfc_hce_reader #
nfc_hce_reader is Flutter plugin for reading NDEF messages on Android and iOS phones. Currently it reads messages from Android phones emulating tags via HCE.
Usage #
StreamSubscription
Example #
class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); }
class _MyAppState extends State
@override void initState() { super.initState(); initPlatformState(); }
Future
}
if (!mounted) return;
}
void _readNFC(BuildContext context) {
StreamSubscription<String> subscription = NfcHceReader.readNFCStream()
.listen((tag) {
setState(() {
_message = tag;
_stream?.cancel();
});
},
onDone: () {
setState(() {
_stream = null;
});
},
onError: (e) {
setState(() {
_stream = null;
});
});
setState(() {
_stream = subscription;
});
}
@override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Plugin example app'), ), body: Center( child: Text('Running on: $_message\n'), ), ), ); } }
Installation #
Add nfc_hce_reader
to your pubspec.yaml
dependencies:
nfc_hce_reader: 0.0.1