showQRScan method

  1. @override
Future<String> showQRScan()
override

Implementation

@override
Future<String> showQRScan() async {
  final completer = Completer<String>();
  methodChannel.setMethodCallHandler((call) async {
    if (call.method == 'qrResult') {
      if (completer.isCompleted) return;
      if (call.arguments == 'scandatatimeout') {
        completer.completeError('TimeOut');
      } else {
        completer.complete(call.arguments);
      }
    }
  });
  methodChannel.invokeMethod('showQRScan');
  return completer.future;
}