invalidate method
Mark this as invalid to be validated at a later time.
Schedule a call to validate to occur at the next frame. Multiple calls to invalidate will not enqueue multiple validations. The Future returned will complete with ValidationStatus.complete when the class is validated and ValidationStatus.cancelled if invalidation is cancelled.
Implementation
Future<ValidationStatus> invalidate() {
if (invalid) {
return _onValidate!.future;
}
final onValidate = Completer<ValidationStatus>();
window.animationFrame.then((_) {
if (invalid) {
validate();
if (!onValidate.isCompleted) {
onValidate.complete(ValidationStatus.complete);
}
}
});
_onValidate = onValidate;
return onValidate.future;
}