68 lines
2.2 KiB
Dart
68 lines
2.2 KiB
Dart
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);
|
|
}
|
|
}
|