multi_device_preview library
Run a Flutter app on multiple device sizes and text scales side by side in a single macOS window, and mirror input on one device to the others.
Classes
- Anchor
- A landmark used to find "the same element" on every device.
- DevicePreset
- Description of a device: its metrics, and optionally the frame it is drawn in.
- DevicePresets
-
The built-in device preset catalog, generated from the
device specs (
device_specs/at the root of the repository) — the same catalog the DevTools panel offers, frame artwork and system UI included. - DeviceSlot
-
Identifies a device instance handed to
appBuilder. - MultiDevicePresets
-
Presets bundled with this package for devices that
device_previewdoes not cover yet. Use them like DevicePresets. - MultiDevicePreview
- Shows one instance of the app per device, side by side, scaled down to fit the window, and mirrors input on the first device to the others.
- MultiDevicePreviewController
-
Holds the configuration of a
MultiDevicePreview: which devices are shown, whether input is mirrored, and which devices fell out of sync. - PreviewCommand
- An action that tools and AI agents can run on a preview: inspect it, switch devices, toggle sync, restart, save screenshots.
- PreviewCommandParam
- A parameter of a PreviewCommand.
- PreviewDevice
- One device shown side by side in the preview: a hardware preset, the text scale the app is rendered with and the orientation the device is held in.
Enums
- PreviewParamType
- The type of a PreviewCommandParam.
Constants
-
defaultPreviewDevices
→ const List<
PreviewDevice> - The devices shown when no devices are given.
Functions
-
imageProviderSource(
ImageProvider< Object> provider) → String? -
Describes where
providerloads from: a URL, an asset or a file path. -
previewCommands(
MultiDevicePreviewController controller) → List< PreviewCommand> -
The commands available for
controller. -
registerPreviewServiceExtensions(
MultiDevicePreviewController controller) → void -
Registers previewCommands as VM service extensions named
ext.multi_device_preview.<command>, so that tools connected to the VM service can drive the preview. -
runMultiDevicePreview(
{required MultiDeviceAppBuilder appBuilder, List< PreviewDevice> devices = defaultPreviewDevices, MultiDevicePreviewController? controller, Widget wrapper(Widget preview)?, TargetPlatform? targetPlatform = TargetPlatform.iOS, bool mouseAsTouch = true, List<AnchorResolver> anchorResolvers = const [], bool registerServiceExtensions = true, String statusBarTime = '9:41'}) → void -
Runs the app built by
appBuilderon each ofdevices, side by side.
Typedefs
- AnchorResolver = Anchor? Function(Element element)
-
Returns the anchor of
element, or null when it has none. - MultiDeviceAppBuilder = Widget Function(BuildContext context, DeviceSlot slot)
-
Builds one instance of the app under preview for
slot.
Exceptions / Errors
- PreviewCommandException
- Thrown by a PreviewCommand when its arguments are invalid.