Devices¶
Pick from 20+ built-in MatrixDevice presets, tweak one with copyWith(), or build a fully custom device — the device axis controls the viewport size and pixel ratio used to render each combination.
Device Presets¶
Generic size classes¶
| Preset | Logical size | Pixel ratio |
|---|---|---|
MatrixDevice.phoneSmall |
375x667 | 2.0x |
MatrixDevice.phoneMedium |
390x844 | 3.0x |
MatrixDevice.phoneLarge |
414x896 | 3.0x |
MatrixDevice.androidSmall |
360x800 | 4.0x |
MatrixDevice.androidMedium |
412x915 | 2.625x |
Modern iPhones¶
| Preset | Logical size | Pixel ratio |
|---|---|---|
MatrixDevice.iphone15Pro |
393x852 | 3.0x |
MatrixDevice.iphone16ProMax |
440x956 | 3.0x |
Modern Android¶
| Preset | Logical size | Pixel ratio |
|---|---|---|
MatrixDevice.pixel8 |
412x915 | 2.625x |
MatrixDevice.pixel8Pro |
448x998 | 2.625x |
MatrixDevice.galaxyS24 |
384x832 | 3.0x |
Foldables¶
| Preset | Logical size | Pixel ratio |
|---|---|---|
MatrixDevice.galaxyZFoldFolded |
374x882 | 3.0x |
MatrixDevice.galaxyZFoldUnfolded |
716x882 | 2.625x |
Tablets / iPad¶
| Preset | Logical size | Pixel ratio |
|---|---|---|
MatrixDevice.tablet |
768x1024 | 2.0x (generic iPad portrait) |
MatrixDevice.tabletLandscape |
1024x768 | 2.0x |
MatrixDevice.ipadMini |
744x1133 | 2.0x |
MatrixDevice.ipadAir |
820x1180 | 2.0x |
MatrixDevice.ipadPro11 |
834x1194 | 2.0x |
MatrixDevice.ipadPro11Landscape |
1194x834 | 2.0x |
MatrixDevice.ipadPro13 |
1024x1366 | 2.0x |
MatrixDevice.ipadPro13Landscape |
1366x1024 | 2.0x |
Legacy named aliases¶
| Alias | Maps to |
|---|---|
MatrixDevice.iphoneSE |
phoneSmall |
MatrixDevice.iphone15 |
phoneMedium |
MatrixDevice.iphone15ProMax |
phoneLarge |
MatrixDevice.galaxyS20 |
androidSmall |
MatrixDevice.galaxyA51 |
androidMedium |
MatrixDevice.ipadPortrait |
tablet |
Custom devices¶
Build one fully from scratch:
What pixelRatio does — and does not¶
MatrixDevice.pixelRatio configures layout, not file resolution:
MediaQuery.of(context).devicePixelRatioreports it, so widgets that branch on density see the real value- resolution-aware asset variants (
2.0x/,3.0x/) are picked according to it, so golden content can differ between devices - the physical viewport size is
logicalSize × pixelRatio
What it does not do is change the size of the PNG. A phoneSmall golden (375×667 @ 2x) is a 375×667 file, not 750×1334 — goldens are captured at logical size, which keeps them small and their diffs readable. This matches golden_toolkit and alchemist.
Need a higher-resolution golden? (since 1.2.0)
Pass captureScale to matrixGolden() / screenMatrixGolden() — it is
the knob for raster resolution, independent of the device:
Useful for supersampled marketing screenshots. Changing it changes the
size of every golden the call produces, so regenerate with
flutter test --update-goldens; the scale is not encoded in the golden
path. For componentMatrixGolden() the equivalent knob is its own
pixelRatio parameter (default 2.0).
Tweaking a preset¶
Use copyWith() to derive a variant — e.g. force a custom name and rotate ipadPro11 to landscape:
final landscape = MatrixDevice.ipadPro11.copyWith(
name: 'ipadPro11Custom',
logicalSize: const Size(1194, 834),
);
copyWith on Models¶
MatrixAxes, MatrixDevice, and MatrixCombination expose copyWith() so you can derive a tweaked instance without re-declaring every field:
// Extend a preset's axes with one extra device
final axes = MatrixPreset.componentFull.axes.copyWith(
devices: [...MatrixPreset.componentFull.axes.devices, MatrixDevice.ipadPro13],
);
// Flip a combination's direction or device in a one-off assertion
final rtl = combination.copyWith(direction: TextDirection.rtl);
Intrinsic-size captures ignore the device axis
In componentMatrixGolden (see Home) the widget is anchored at its natural size, so the devices field of MatrixAxes is ignored and no device segment appears in the golden path.
See also¶
- Sampling — control how many combinations across these device axes get rendered
- Reports
- CI integration
- Advanced
- Migration guide
- Home