setSurfaceSize method

Future<void> setSurfaceSize(
  1. Size? size

Artificially changes the logical size of WidgetTester.view to the specified size, 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:

  await binding.setSurfaceSize(someSize);
  addTearDown(() => binding.setSurfaceSize(null));

This method only affects the size of the WidgetTester.view. It does not affect the size of any other views. Instead of this method, consider setting TestFlutterView.physicalSize, which works for any view, including WidgetTester.view.


// TODO(pdblasi-google): Deprecate this.
Future<void> setSurfaceSize(Size? size) {
  return TestAsyncUtils.guard<void>(() async {
    if (_surfaceSize == size) {
    _surfaceSize = size;