DevicePreview class
Simulates how the result of builder would render on different devices.
{@tool snippet}
This sample shows how to define an app with a plugin.
DevicePreview(
builder: (context) => MyApp(),
plugins: [
const ScreenshotPlugin(),
],
)
{@end-tool}
See also :
- Devices has a set of predefined common devices.
- DevicePreviewStyle to update the aspect.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- DevicePreview
Constructors
-
DevicePreview({Key? key, required WidgetBuilder builder, List<
DeviceInfo> ? devices, DevicePreviewData? data, DevicePreviewStyle? style, bool isToolbarVisible = true, List<Locale> ? availableLocales, DeviceInfo? defaultDevice, List<DevicePreviewPlugin> plugins = const <DevicePreviewPlugin>[], DevicePreviewStorage? storage, bool enabled = true}) - Create a new DevicePreview.
Properties
-
availableLocales
→ List<
Locale> ? -
The available locales.
final
- builder → WidgetBuilder
-
The previewed widget.
final
- data → DevicePreviewData?
-
The configuration. If not precised, it is loaded from preferences.
final
- defaultDevice → DeviceInfo?
-
The default selected device when opening device preview for the first time.
final
-
devices
→ List<
DeviceInfo> ? -
The available devices used for previewing.
final
- enabled → bool
-
If not enabled, the
child
is used directly.final - hashCode → int
-
The hash code for this object.
no setterinherited
- isToolbarVisible → bool
-
Indicates whether the tool bar should be visible or not.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
plugins
→ List<
DevicePreviewPlugin> -
The list of plugins.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- storage → DevicePreviewStorage
-
The storage used to persist preferences.
final
- style → DevicePreviewStyle?
-
Customizing the tool bar and background aspect.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _DevicePreviewState -
Creates the mutable state for this widget at a given location in the tree.
override
-
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.
inherited
-
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}) → 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 Properties
-
defaultDevices
→ List<
DeviceInfo> -
final
Static Methods
-
allLocales(
BuildContext context) → List< Locale> - All available locales in the tool.
-
hideToolbar(
BuildContext context, {bool disablePreview = true}) → void - Hide the toolbar.
-
locale(
BuildContext context) → Locale? - Currently defined locale.
-
platform(
BuildContext context) → TargetPlatform - The current target platform for the currently selected device.
-
pluginsOf(
BuildContext context) → List< DevicePreviewPlugin> - The list of declared plugins.
-
screenshot(
BuildContext context) → Future< DeviceScreenshot> - Take a screenshot.
-
selectDevice(
BuildContext context, DeviceIdentifier deviceIdentifier) → void -
Select a device from its unique
deviceIdentifier
. -
showToolbar(
BuildContext context, {bool enablePreview = true}) → void - Make the toolbar visible to the user.