cleanup method

Future<void> cleanup()

Implementation

Future<void> cleanup() async {
  final Set entriesToDispose = <String>{};
  for (final entry in _requests.entries) {
    var dispose = entry.value.canceled ||
        entry.value.state == KeyVerificationState.done ||
        entry.value.state == KeyVerificationState.error;
    if (!dispose) {
      dispose = !(await entry.value.verifyActivity());
    }
    if (dispose) {
      entry.value.dispose();
      entriesToDispose.add(entry.key);
    }
  }
  entriesToDispose.forEach(_requests.remove);
}