yubioath-flutter/lib/desktop/qr_scanner.dart

21 lines
572 B
Dart
Raw Normal View History

2022-02-10 17:24:28 +03:00
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:yubico_authenticator/app/state.dart';
import 'package:yubico_authenticator/desktop/state.dart';
import 'rpc.dart';
class RpcQrScanner implements QrScanner {
final RpcSession _rpc;
RpcQrScanner(this._rpc);
@override
2022-03-29 14:57:08 +03:00
Future<String> scanQr([String? imageData]) async {
final result = await _rpc.command('qr', [], params: {'image': imageData});
return result['result'];
2022-02-10 17:24:28 +03:00
}
}
final desktopQrScannerProvider = Provider<QrScanner?>(
(ref) => RpcQrScanner(ref.watch(rpcProvider)),
);