Skip to content

Commit e2cc32e

Browse files
committed
Clarify deferred invariant verification scope
1 parent a65e60e commit e2cc32e

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎packages/flutter_test/lib/src/binding.dart‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,6 +1988,10 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
19881988
bool _pendingInvariantVerification = false;
19891989

19901990
/// Defers invariant verification until [verifyInvariantsAfterTestTearDown].
1991+
///
1992+
/// This is used by [testWidgets], which can install package:test tearDown
1993+
/// callbacks around [runTest]. Direct [runTest] callers still verify
1994+
/// invariants before [postTest].
19911995
@protected
19921996
void deferInvariantsUntilAfterTestTearDown() {
19931997
_verifyInvariantsAfterTestTearDown = true;

‎packages/flutter_test/lib/src/widget_tester.dart‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ void testWidgets(
180180
if (semanticsEnabled) {
181181
semanticsHandle = tester.ensureSemantics();
182182
}
183-
// Invariant verification must run after user addTearDown callbacks and before postTest.
183+
// testWidgets owns the package:test tearDown callbacks, so it can
184+
// defer binding invariant verification until after user addTearDown
185+
// callbacks and before postTest. Lower-level binding.runTest callers
186+
// keep the immediate invariant check inside runTest.
184187
// ignore: invalid_use_of_protected_member
185188
binding.deferInvariantsUntilAfterTestTearDown();
186189
test_package.addTearDown(binding.postTest);

0 commit comments

Comments
 (0)