verifyAllScopesClosed method
Verifies that there are no guarded methods currently pending (see guard).
This is used at the end of tests to ensure that nothing leaks out of the test.
Implementation
static void verifyAllScopesClosed() {
if (_scopeStack.isNotEmpty) {
final StringBuffer message = StringBuffer();
message.writeln('Asynchronous call to guarded function leaked. You must use "await" with all Future-returning test APIs.');
for (_AsyncScope scope in _scopeStack) {
final _StackEntry guarder = _findResponsibleMethod(scope.creationStack, 'guard', message);
if (guarder != null) {
message.writeln(
'The guarded method "${guarder.methodName}" '
'${guarder.className != null ? "from class ${guarder.className} " : ""}'
'was called from ${guarder.callerFile} '
'on line ${guarder.callerLine}, '
'but never completed before its parent scope closed.'
);
}
}
throw FlutterError(message.toString().trimRight());
}
}