dispose method
Implementation
Future<void> dispose({final Function(LedgerException)? onError}) async {
switch (_connectionManager.connectionType) {
case ConnectionType.usb:
_ledgerUsb = null;
case ConnectionType.ble:
_ledgerBle = null;
}
try {
await stopScanning();
} catch (ex) {
// no-op
}
try {
await _connectionManager.dispose();
} catch (ex) {
if (onError != null) {
onError(
DisposeException(
connectionType: _connectionManager.connectionType,
cause: ex,
),
);
}
}
}