getScreenSize function
ScreenSize
getScreenSize({
- required double width,
- Orientation? orientation,
- LayoutSize defaultSize = LayoutSize.mobile,
- ScreenSizeSettings sizes = const ScreenSizeSettings.portrait(),
Gets type of screen size based on width
sizes
defaults to ScreenSizeSettings.portrait()
defaultSize
defaults to LayoutSize.mobile
orientation
is mostly needed for ResponsiveLayoutBuilder
width
must not be null
Implementation
ScreenSize getScreenSize({
required double width,
Orientation? orientation,
LayoutSize defaultSize = LayoutSize.mobile,
ScreenSizeSettings sizes = const ScreenSizeSettings.portrait(),
}) {
LayoutSize size;
MobileLayoutSize? mobile;
TabletLayoutSize? tablet;
if (width <= sizes.watch) {
size = LayoutSize.watch;
} else if (width > sizes.watch && width <= sizes.largeMobile) {
size = LayoutSize.mobile;
mobile = getMobileLayoutSize(sizes: sizes, width: width);
} else if (width > sizes.largeMobile && width <= sizes.largeTablet) {
size = LayoutSize.tablet;
tablet = getTabletLayoutSize(sizes: sizes, width: width);
} else if (width > sizes.largeTablet) {
size = LayoutSize.desktop;
} else {
size = defaultSize;
}
return ScreenSize(
size: size,
mobile: mobile,
tablet: tablet,
orientation: orientation,
);
}