scan_code_handler.dart
559 Bytes
import 'dart:async';
import 'package:appframe/bloc/web_cubit.dart';
import 'package:appframe/services/dispatcher.dart';
class ScanCodeHandler extends MessageHandler {
late WebCubit? _webCubit;
@override
Future<dynamic> handleMessage(params) async {
try {
final result = await _webCubit!.goScanCode();
// 返回扫码结果
return result;
} finally {
_unfollowCubit();
}
}
@override
void setCubit(WebCubit cubit) {
this._webCubit = cubit;
}
void _unfollowCubit() {
this._webCubit = null;
}
}