setSurfaceSize method

Future<void> setSurfaceSize(
  1. Size? size

Artificially changes the surface size to size on the Widget binding, 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));

See also TestFlutterView.physicalSize, which has a similar effect.


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