loki.wu 9de0919646 初始化仓库 | 7 months ago | |
---|---|---|
.. | ||
android | 7 months ago | |
lib | 7 months ago | |
.gitignore | 7 months ago | |
README.md | 7 months ago | |
pubspec.lock | 7 months ago | |
pubspec.yaml | 7 months ago |
开启权限
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
idread:
git:
https://github.com/hisan-web/flutter_id_read.git
Idread.init() // 初始化sdk
Idread.startRead() // 开始读卡
Idread.stopRead() // 结束读卡
Idread.unInit() // 销毁sdk
// 监听读卡数据
Idread.dataStreamListen((data) {
print(data.toString());
});
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:idread/idread.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
@override
void initState() {
super.initState();
init();
}
@override
void dispose() {
super.dispose();
Idread.stopRead();
unInit();
}
Future<void> unInit() async {
await Idread.unInit();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> init() async {
bool result = await Idread.init();
if (result) {
bool start = await Idread.startRead();
if( start ) {
Idread.dataStreamListen((data) {
print(data.toString());
});
}
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('Running on: $_platformVersion\n'),
),
),
);
}
}