formFactor method
Returns the correct FormFactor based on the ScreenWidthBreakpoints.
If followDeviceOrientation
is true (default) the devices screen width
is compared with the ScreenWidthBreakpoints. This means the FormFactor
changes when the device orientation changes.
If followDeviceOrientation
is false the devices shortest side
is compared with the ScreenWidthBreakpoints. This means the FormFactor
does not change when the device orientation changes.
Implementation
FormFactor formFactor({bool followDeviceOrientation = true}) {
final width = followDeviceOrientation
? mediaQuery.size.width
: mediaQuery.size.shortestSide;
return width > ScreenWidthBreakpoints.desktop
? FormFactor.desktop
: width > ScreenWidthBreakpoints.tablet
? FormFactor.tablet
: FormFactor.mobile;
}