resolve method
Resolves this preset into a metrics-only DeviceSimulation with DeviceSimulation.presetId set.
For Orientation.landscape, the screen dimensions are swapped and the preset's explicit landscape safe areas are used when available; otherwise they are derived by rotateToLandscape. Display features (expressed in portrait coordinates) are mapped through the 90° rotation (SimulatedDisplayFeature.rotatedToLandscape) so hinge/fold geometry stays physically correct. systemGestureInsets intentionally pass through unrotated: their edge semantics (back-gesture side edges, home area at the bottom) are orientation-invariant on real devices.
Implementation
DeviceSimulation resolve({Orientation orientation = Orientation.portrait}) {
final EdgeInsets effectivePortraitViewPadding =
portraitViewPadding ?? portraitPadding;
if (orientation == Orientation.portrait) {
return DeviceSimulation(
presetId: id,
deviceKind: kind,
screenSize: portraitSize,
frame: frame,
systemUi: systemUi,
devicePixelRatio: devicePixelRatio,
padding: portraitPadding,
viewPadding: effectivePortraitViewPadding,
systemGestureInsets: systemGestureInsets,
displayFeatures: displayFeatures.isEmpty ? null : displayFeatures,
);
}
final EdgeInsets resolvedLandscapePadding =
landscapePadding ?? rotateToLandscape(portraitPadding);
final EdgeInsets resolvedLandscapeViewPadding =
landscapeViewPadding ??
landscapePadding ??
rotateToLandscape(effectivePortraitViewPadding);
return DeviceSimulation(
presetId: id,
deviceKind: kind,
orientation: Orientation.landscape,
screenSize: ui.Size(portraitSize.height, portraitSize.width),
// Frames are described in portrait and rotated at paint time.
frame: frame,
// System bars follow the safe areas, which resolve() already rotated.
systemUi: systemUi,
devicePixelRatio: devicePixelRatio,
padding: resolvedLandscapePadding,
viewPadding: resolvedLandscapeViewPadding,
systemGestureInsets: systemGestureInsets,
displayFeatures: displayFeatures.isEmpty
? null
: List<SimulatedDisplayFeature>.unmodifiable(
displayFeatures.map(
(SimulatedDisplayFeature feature) =>
feature.rotatedToLandscape(portraitSize.width),
),
),
);
}