diff --git a/packages/flutter/test/material/paginated_data_table_test.dart b/packages/flutter/test/material/paginated_data_table_test.dart index 0e72cbc4ab..b68223c4b1 100644 --- a/packages/flutter/test/material/paginated_data_table_test.dart +++ b/packages/flutter/test/material/paginated_data_table_test.dart @@ -2,13 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO(gspencergoog): Remove this tag once this test's state leaks/test -// dependencies have been fixed. -// https://github.com/flutter/flutter/issues/85160 -// Fails with "flutter test --test-randomize-ordering-seed=1000" -@Tags(['no-shuffle']) -library; - import 'package:flutter/gestures.dart' show DragStartBehavior; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; @@ -845,6 +838,7 @@ void main() { testWidgets('PaginatedDataTable with optional column checkbox', (WidgetTester tester) async { await binding.setSurfaceSize(const Size(800, 800)); + addTearDown(() => binding.setSurfaceSize(null)); Widget buildTable(bool checkbox) => MaterialApp( home: PaginatedDataTable( @@ -1004,6 +998,7 @@ void main() { testWidgets('PaginatedDataTable arrowHeadColor set properly', (WidgetTester tester) async { await binding.setSurfaceSize(const Size(800, 800)); + addTearDown(() => binding.setSurfaceSize(null)); const Color arrowHeadColor = Color(0xFFE53935); await tester.pumpWidget( diff --git a/packages/flutter_test/lib/src/binding.dart b/packages/flutter_test/lib/src/binding.dart index bcc629a6e0..d6b7fbdd1b 100644 --- a/packages/flutter_test/lib/src/binding.dart +++ b/packages/flutter_test/lib/src/binding.dart @@ -505,6 +505,17 @@ abstract class TestWidgetsFlutterBinding extends BindingBase /// then flushes microtasks. /// /// Set to null to use the default surface size. + /// + /// To avoid affecting other tests by leaking state, a test that + /// uses this method should always reset the surface size to the default. + /// For example, using `addTearDown`: + /// ```dart + /// await binding.setSurfaceSize(someSize); + /// addTearDown(() => binding.setSurfaceSize(null)); + /// ``` + /// + /// See also [TestFlutterView.physicalSize], which has a similar effect. + // TODO(pdblasi-google): Deprecate this. https://github.com/flutter/flutter/issues/123881 Future setSurfaceSize(Size? size) { return TestAsyncUtils.guard(() async { assert(inTest);