waitForElementToBeRemoved
Future<
Waits for an element to be removed from the DOM.
Implementation
Future<void> waitForElementToBeRemoved(
DomNode? Function() callback, {
Duration timeout = const Duration(seconds: 1),
Duration interval = const Duration(milliseconds: 50),
}) async {
final initial = callback();
if (initial == null) {
throw TestingLibraryException(
'Element not found initially. waitForElementToBeRemoved requires the '
'element to be present before waiting for removal.',
);
}
final deadline = DateTime.now().add(timeout);
while (DateTime.now().isBefore(deadline)) {
if (callback() == null) return;
await Future<void>.delayed(interval);
}
throw TestingLibraryException('Timed out waiting for element to be removed.');
}