sendCommandBundle method
- @Deprecated('This is for backwards compatibility and only support Zebra devices, this will be removed later')
Future<bool>
sendCommandBundle(
{ - required String command,
- required Map<String, dynamic> parameter,
- required bool sendResult,
})
Implementation
@Deprecated('This is for backwards compatibility and only support Zebra devices, this will be removed later')
Future<bool> sendCommandBundle({required String command, required Map<String, dynamic> parameter, required bool sendResult}) async {
if (!isDeviceSupported) return false;
debugPrint('sendCommandBundle-$isDeviceSupported');
final completer = sendResult ? (completerSendCommandBundle = Completer()) : null;
final invoked = await _methodChannel.invokeMethod<bool>('sendCommandBundle', {'command': command, 'parameter': parameter, 'sendResult': sendResult});
if (invoked == true && completer != null) {
// Guard against the native 'result' callback never arriving (e.g. command
// rejected after the ack), which would otherwise hang this future forever.
_lastCompleterError = await completer.future.timeout(
const Duration(seconds: 15),
onTimeout: () {
log('sendCommandBundle: timed out waiting for result');
return 'TIMEOUT';
},
);
// Only clear if a newer call hasn't already replaced it.
if (identical(completerSendCommandBundle, completer)) completerSendCommandBundle = null;
log('sendCommandBundle: $_lastCompleterError');
return _lastCompleterError == 'OK';
}
return invoked == true;
}