kdfStop method

Future<StopStatus> kdfStop()

Implementation

Future<StopStatus> kdfStop() async {
  _log('Stopping KDF...');
  final result = await _kdfOperations.kdfStop();
  _log('KDF stop result: $result');
  // Await a max of 5 seconds for KDF to stop. Check every 500ms.
  for (var i = 0; i < 10; i++) {
    await Future<void>.delayed(const Duration(milliseconds: 500));
    if (!await isRunning()) {
      break;
    }
    if (i == 9) {
      throw Exception('Error stopping KDF: KDF did not stop in time.');
    }
  }

  return result;
}