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 carry the complete spec — frame artwork
and systemUi included. They are generated from the device spec catalog
shared with the DevTools extension (device_specs/ at the root of the
repository); 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, double? portraitKeyboardHeight, double? landscapeKeyboardHeight, 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
- landscapeKeyboardHeight → double?
-
The height the device's software keyboard covers in landscape, in
logical pixels. See portraitKeyboardHeight.
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
- portraitKeyboardHeight → double?
-
The height the device's software keyboard covers in portrait, in
logical pixels, or null when the device has no software keyboard (a
desktop window) or its height has not been measured.
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
-
keyboardHeight(
Orientation orientation) → double? -
The keyboard height for
orientation, or null when this device declares none. -
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: