This commit is contained in:
2026-04-13 16:03:06 +08:00
parent e9f4844352
commit dc30881d38
4 changed files with 115 additions and 16 deletions

View File

@@ -1,5 +1,6 @@
import 'zhiwen_platform_interface.dart';
import 'dart:async';
class Zhiwen {
Future<String?> getPlatformVersion() {
@@ -37,4 +38,10 @@ class Zhiwen {
Future<Map<String, dynamic>> getUserCount() {
return ZhiwenPlatform.instance.getUserCount();
}
/// 获取指纹录入进度事件流
/// 返回包含 step, totalSteps, progress, message 的 Map
Stream<Map<String, dynamic>> get progressStream {
return ZhiwenPlatform.instance.progressStream;
}
}

View File

@@ -1,5 +1,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'dart:async';
import 'zhiwen_platform_interface.dart';
@@ -9,6 +10,13 @@ class MethodChannelZhiwen extends ZhiwenPlatform {
@visibleForTesting
final methodChannel = const MethodChannel('zhiwen');
/// The event channel for receiving fingerprint enrollment progress.
@visibleForTesting
final progressEventChannel = const EventChannel('zhiwen_progress');
/// 进度事件流控制器
Stream<Map<String, dynamic>>? _progressStream;
@override
Future<String?> getPlatformVersion() async {
final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
@@ -64,4 +72,13 @@ class MethodChannelZhiwen extends ZhiwenPlatform {
final result = await methodChannel.invokeMethod('getUserCount');
return Map<String, dynamic>.from(result as Map);
}
/// 获取指纹录入进度事件流
@override
Stream<Map<String, dynamic>> get progressStream {
_progressStream ??= progressEventChannel
.receiveBroadcastStream()
.map((event) => Map<String, dynamic>.from(event as Map));
return _progressStream!;
}
}

View File

@@ -1,4 +1,5 @@
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'dart:async';
import 'zhiwen_method_channel.dart';
@@ -24,6 +25,11 @@ abstract class ZhiwenPlatform extends PlatformInterface {
Future<Map<String, dynamic>> deleteOneFingerprint(int userId);
Future<Map<String, dynamic>> identifyFingerprint();
Future<Map<String, dynamic>> getUserCount();
/// 获取指纹录入进度事件流
/// 返回包含 step, totalSteps, progress, message 的 Map
Stream<Map<String, dynamic>> get progressStream;
/// Platform-specific implementations should set this with their own
/// platform-specific class that extends [ZhiwenPlatform] when
/// they register themselves.