csht_nfc_reader 0.0.1
csht_nfc_reader: ^0.0.1 copied to clipboard
中软高科NFC身份证云解码插件.
example/lib/main.dart
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:csht_nfc_reader/nfc_reader.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final NfcReader _nfcReader = NfcReader();
String text = '';
@override
void initState() {
super.initState();
_nfcReader.init('xxxxxxx', _onEvent);
}
_onEvent(data) {
setState(() {
text = jsonEncode(data);
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: const Center(
child: Text('Test'),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
_nfcReader.start();
},
child: const Icon(Icons.add),
),
),
);
}
}