init
This commit is contained in:
40
lib/zhiwen.dart
Normal file
40
lib/zhiwen.dart
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
import 'zhiwen_platform_interface.dart';
|
||||
|
||||
class Zhiwen {
|
||||
Future<String?> getPlatformVersion() {
|
||||
return ZhiwenPlatform.instance.getPlatformVersion();
|
||||
}
|
||||
|
||||
Future<bool> openDevice(String devicePath, int baudRate) {
|
||||
return ZhiwenPlatform.instance.openDevice(devicePath, baudRate);
|
||||
}
|
||||
|
||||
Future<void> closeDevice() {
|
||||
return ZhiwenPlatform.instance.closeDevice();
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> enrollFingerprint(int userId) {
|
||||
return ZhiwenPlatform.instance.enrollFingerprint(userId);
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> verifyFingerprint(int userId) {
|
||||
return ZhiwenPlatform.instance.verifyFingerprint(userId);
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> deleteAllFingerprint() {
|
||||
return ZhiwenPlatform.instance.deleteAllFingerprint();
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> deleteOneFingerprint(int userId) {
|
||||
return ZhiwenPlatform.instance.deleteOneFingerprint(userId);
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> identifyFingerprint() {
|
||||
return ZhiwenPlatform.instance.identifyFingerprint();
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getUserCount() {
|
||||
return ZhiwenPlatform.instance.getUserCount();
|
||||
}
|
||||
}
|
||||
67
lib/zhiwen_method_channel.dart
Normal file
67
lib/zhiwen_method_channel.dart
Normal file
@@ -0,0 +1,67 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'zhiwen_platform_interface.dart';
|
||||
|
||||
/// An implementation of [ZhiwenPlatform] that uses method channels.
|
||||
class MethodChannelZhiwen extends ZhiwenPlatform {
|
||||
/// The method channel used to interact with the native platform.
|
||||
@visibleForTesting
|
||||
final methodChannel = const MethodChannel('zhiwen');
|
||||
|
||||
@override
|
||||
Future<String?> getPlatformVersion() async {
|
||||
final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
|
||||
return version;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> openDevice(String devicePath, int baudRate) async {
|
||||
final result = await methodChannel.invokeMethod<bool>(
|
||||
'openDevice',
|
||||
{'devicePath': devicePath, 'baudRate': baudRate},
|
||||
);
|
||||
return result ?? false;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> closeDevice() async {
|
||||
await methodChannel.invokeMethod('closeDevice');
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> enrollFingerprint(int userId) async {
|
||||
final result = await methodChannel.invokeMethod('enrollFingerprint', {'userId': userId});
|
||||
return Map<String, dynamic>.from(result as Map);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> verifyFingerprint(int userId) async {
|
||||
final result = await methodChannel.invokeMethod('verifyFingerprint', {'userId': userId});
|
||||
return Map<String, dynamic>.from(result as Map);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> deleteAllFingerprint() async {
|
||||
final result = await methodChannel.invokeMethod('deleteAllFingerprint');
|
||||
return Map<String, dynamic>.from(result as Map);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> deleteOneFingerprint(int userId) async {
|
||||
final result = await methodChannel.invokeMethod('deleteOneFingerprint', {'userId': userId});
|
||||
return Map<String, dynamic>.from(result as Map);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> identifyFingerprint() async {
|
||||
final result = await methodChannel.invokeMethod('identifyFingerprint');
|
||||
return Map<String, dynamic>.from(result as Map);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, dynamic>> getUserCount() async {
|
||||
final result = await methodChannel.invokeMethod('getUserCount');
|
||||
return Map<String, dynamic>.from(result as Map);
|
||||
}
|
||||
}
|
||||
38
lib/zhiwen_platform_interface.dart
Normal file
38
lib/zhiwen_platform_interface.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
||||
|
||||
import 'zhiwen_method_channel.dart';
|
||||
|
||||
abstract class ZhiwenPlatform extends PlatformInterface {
|
||||
/// Constructs a ZhiwenPlatform.
|
||||
ZhiwenPlatform() : super(token: _token);
|
||||
|
||||
static final Object _token = Object();
|
||||
|
||||
static ZhiwenPlatform _instance = MethodChannelZhiwen();
|
||||
|
||||
/// The default instance of [ZhiwenPlatform] to use.
|
||||
///
|
||||
/// Defaults to [MethodChannelZhiwen].
|
||||
static ZhiwenPlatform get instance => _instance;
|
||||
|
||||
Future<String?> getPlatformVersion();
|
||||
Future<bool> openDevice(String devicePath, int baudRate);
|
||||
Future<void> closeDevice();
|
||||
Future<Map<String, dynamic>> enrollFingerprint(int userId);
|
||||
Future<Map<String, dynamic>> verifyFingerprint(int userId);
|
||||
Future<Map<String, dynamic>> deleteAllFingerprint();
|
||||
Future<Map<String, dynamic>> deleteOneFingerprint(int userId);
|
||||
Future<Map<String, dynamic>> identifyFingerprint();
|
||||
Future<Map<String, dynamic>> getUserCount();
|
||||
/// Platform-specific implementations should set this with their own
|
||||
/// platform-specific class that extends [ZhiwenPlatform] when
|
||||
/// they register themselves.
|
||||
static set instance(ZhiwenPlatform instance) {
|
||||
PlatformInterface.verifyToken(instance, _token);
|
||||
_instance = instance;
|
||||
}
|
||||
|
||||
// Future<String?> getPlatformVersion() {
|
||||
// throw UnimplementedError('platformVersion() has not been implemented.');
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user