PreviewFrame class
The frame a preview stands in: publishes its platform and brightness to everything inside it, scopes the platform override there, and publishes its box as the screen.
- The platform: targetPlatformOf reads it inside the frame, and the
frame's scroll behaviour follows it. (An app built inside the frame
installs its own scroll behaviour; a Material one follows
ThemeData.platform, which the host sets from targetPlatformOf.) - The brightness:
MediaQuery.platformBrightnessreads it, so a host or an app that follows the platform's brightness follows the frame. - The box: with device false the frame's box is the phone — its size
is published as
MediaQuery.size, and a box smaller than the view (a phone framed on a page) stands without the view's safe-area insets. With device true the child is laid out at the platform's PreviewDevice size, without insets, and scaled to fit the box.
Placed outside any app the preview builds, so the app reads the frame's media query.
PreviewFrame(platform: PreviewPlatform.ios, brightness: Brightness.dark, child: const Text('App'))
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- PreviewFrame
Constructors
- PreviewFrame({required Widget child, PreviewPlatform platform = PreviewPlatform.android, Brightness brightness = Brightness.light, bool device = false, Key? key})
-
Creates a PreviewFrame.
const
Properties
- brightness → Brightness
-
The brightness published as the platform's.
final
- child → Widget
-
What stands in the frame: usually the preview's own app.
final
- device → bool
-
Whether the child is laid out at the platform's device size and scaled
to fit, rather than filling the frame's box.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- platform → PreviewPlatform
-
The platform the frame is drawn for.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
maybeOf(
BuildContext context) → PreviewFrameData? - The nearest frame's data, or null outside any preview frame.
-
targetPlatformOf(
BuildContext context) → TargetPlatform -
The platform whose behaviour applies at
context: the preview frame's platform inside one, else the device's own platform. A host reads this instead of pinning a platform.