Se agrego el sdk para el pda de honeywell
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class ScanLaunchService {
|
||||
ScanLaunchService._();
|
||||
|
||||
static final ScanLaunchService instance = ScanLaunchService._();
|
||||
|
||||
static const _methodChannel = MethodChannel('com.example.qrscanner/scan_launch');
|
||||
static const _eventChannel = EventChannel('com.example.qrscanner/scan_events');
|
||||
|
||||
Stream<String>? _scanStream;
|
||||
|
||||
bool get isAndroid => !kIsWeb && Platform.isAndroid;
|
||||
|
||||
Stream<String> get scanStream {
|
||||
_scanStream ??= _eventChannel
|
||||
.receiveBroadcastStream()
|
||||
.where((event) => event is String && event.trim().isNotEmpty)
|
||||
.map((event) => (event as String).trim());
|
||||
return _scanStream!;
|
||||
}
|
||||
|
||||
Future<bool> isSupported() async {
|
||||
if (!isAndroid) return false;
|
||||
try {
|
||||
final supported = await _methodChannel.invokeMethod<bool>('isSupported');
|
||||
return supported ?? false;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> claimScanner() async {
|
||||
if (!isAndroid) return;
|
||||
try {
|
||||
await _methodChannel.invokeMethod<void>('claimScanner');
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
Future<void> releaseScanner() async {
|
||||
if (!isAndroid) return;
|
||||
try {
|
||||
await _methodChannel.invokeMethod<void>('releaseScanner');
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
Future<String?> consumePendingScan() async {
|
||||
if (!isAndroid) return null;
|
||||
try {
|
||||
final code = await _methodChannel.invokeMethod<String>('consumePendingScan');
|
||||
final trimmed = code?.trim();
|
||||
if (trimmed == null || trimmed.isEmpty) return null;
|
||||
return trimmed;
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user