widgetbook_models 0.0.1 widgetbook_models: ^0.0.1 copied to clipboard
A package that combines commonly used models from the widgetbook packages.
Introduction #
This package features the models for the Widgetbook Device
class. The device
class is used in the following packages:
Furthermore, the package contains predefined and commonly used devices.
NOTE: It is not required to add this package to your project. package:widgetbook_models was designed to make the classes defined accessible to the other packages. package:widgetbook exports the classes defined in the package so you can use them without needing to import anything else than package:widgetbook.
Classes #
Currently the package contains the Device
class with its required subsclasses and collections of various devices.
Resolution #
A device's screen resolution is defined by the number of distinct pixels in each dimension that can be displayed. Furthermore, on Apple and Android devices, this resolution is divided into logical and native resolution by a scaling factor. Therefore, to define a resolution, the native amount of pixels in each dimension and a scaling factor is required.
A Resolution
instance is created by using
Resolution(
nativeSize: DeviceSize(width: 1668, height: 2388),
scaleFactor: 2,
),
DeviceSize
is similar to Size
from the Flutter SDK and contains properties for width
and height
.
Device #
The device class specifies a device like the iPhone 12 based on a name
, its resolution
and its type
. type
is primarily used for better iconization in package:widgetbook's user interface.
An Apple iPhone 12 can be defined by using
Device iPhone12 = Device(
name: 'iPhone 12',
resolution: Resolution(
nativeSize: DeviceSize(width: 1170, height: 2532),
scaleFactor: 3,
),
type, DeviceType.mobile,
);
Device Types #
The following device types exist and can be accessed with the respective Device
constructor:
Device.watch( ... )
Device.mobile( ... )
Device.tablet( ... )
Device.desktop( ... )
Device.special( ... )
- used for screens with unusual apsect ratios.
Collections #
This package also features commonly used devices like various iPads, iPhone and Macs as well as Android devices like the Samsung Galaxy Series.
The collections can be accessed by using the respective collection identifier. For instance:
Device iPhone11 = Apple.iPhone11;
The following collections exist:
Collection | Annotation |
---|---|
Apple | iPhone, iPad, iMac, MacBook, Pro Display XDR |
Samsung | Galaxy Series |
Desktop | HD (1080p), 2K (1440p), 4K (2180p) |
The specified identifiers of the collections are easily accessible via IntelliSense.