applyDevice method
VoidCallback
applyDevice(
- Device? device, {
- ScreenOrientation? orientation,
- KeyboardMode? keyboard,
Renders as device until the returned callback is run.
Run the reset inside the test body — a tearDown is too late. The
binding verifies its foundation debug variables at the end of the body,
debugDefaultTargetPlatformOverride among them, and tearDowns run after
that. So a reset filed as a tearDown fails the test it was meant to clean
up. Forgetting it entirely fails loudly for the same reason, which is the
one thing to be grateful for here.
A null device is the plain surface and a reset that does nothing, so a
caller looking a device up per entry needs no branch around this.
Implementation
VoidCallback applyDevice(
Device? device, {
ScreenOrientation? orientation,
KeyboardMode? keyboard,
}) {
if (device == null) return () {};
var reset = applyScenarioRunArgs(
this,
const ScenarioRunArgs().withDevice(device, orientation: orientation),
);
if (keyboard == KeyboardMode.up) {
stageKeyboard(this, device.oriented(orientation).keyboard);
}
return reset;
}