DevicePreset class

Description of a device: its metrics, and optionally the frame it is drawn in.

Metric fields are expressed for the portrait orientation; landscape values are either provided explicitly or derived by the documented rotation rule (see rotateToLandscape).

The built-in DevicePresets are metrics-only — no artwork ships in the package. Frames come from the device spec catalog of the DevTools extension (device_specs/ at the root of the repository), which pushes them over the simulation protocol; fromJson decodes exactly that catalog format, so a spec file can also be loaded directly by an app that wants a framed golden test.

Annotations

Constructors

DevicePreset({required String id, required String name, required TargetPlatform platform, required Size portraitSize, required double devicePixelRatio, String? brand, int? year, DeviceFrame? frame, SystemUiSimulation? systemUi, EdgeInsets portraitPadding = EdgeInsets.zero, EdgeInsets? portraitViewPadding, EdgeInsets? landscapePadding, EdgeInsets? landscapeViewPadding, EdgeInsets systemGestureInsets = EdgeInsets.zero, List<SimulatedDisplayFeature> displayFeatures = const <SimulatedDisplayFeature>[], DeviceKind kind = DeviceKind.phone})
Creates a device preset.
const
DevicePreset.fromJson(Map<String, Object?> json)
Decodes a preset from the JSON produced by toJson.
factory

Properties

brand String?
The manufacturer, e.g. 'Apple'. Null when unspecified.
final
devicePixelRatio double
The device pixel ratio.
final
displayFeatures List<SimulatedDisplayFeature>
Display features (folds, hinges, cutouts), in portrait logical pixels.
final
frame DeviceFrame?
The device's screen outline and body artwork, or null for a plain rectangular screen with no artwork.
final
hashCode int
The hash code for this object.
no setteroverride
id String
Stable identifier, e.g. 'apple-iphone-16-pro'.
final
kind DeviceKind
The broad category of the device.
final
landscapePadding EdgeInsets?
The landscape safe-area padding; when null, derived from portraitPadding by the rotation rule (rotateToLandscape).
final
landscapeViewPadding EdgeInsets?
The landscape view padding; when null, follows landscapePadding, or the rotation rule applied to the effective portrait view padding.
final
name String
Human-readable name, e.g. 'iPhone 16 Pro'.
final
platform TargetPlatform
The platform of the device.
final
portraitPadding EdgeInsets
The portrait safe-area padding, in logical pixels.
final
portraitSize Size
The logical screen size in portrait orientation.
final
portraitViewPadding EdgeInsets?
The portrait view padding; defaults to portraitPadding when null.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
systemGestureInsets EdgeInsets
The system gesture insets, in logical pixels.
final
systemUi SystemUiSimulation?
The device's decorative system UI (status bar, gesture pill), or null to leave the screen bare.
final
year int?
The year the device was released, e.g. 2025. Null when unspecified.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolve({Orientation orientation = Orientation.portrait}) DeviceSimulation
Resolves this preset into a metrics-only DeviceSimulation with DeviceSimulation.presetId set.
toJson() Map<String, Object?>
Encodes this preset as JSON. Null fields are absent.
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override

Static Methods

rotateToLandscape(EdgeInsets portrait) EdgeInsets
The documented rotation rule for deriving landscape safe areas from portrait ones: