valueByScreen<T> method
T
valueByScreen<T>({
- required T mobile,
- T? watch,
- T? tablet,
- T? smallDesktop,
- T? desktop,
- T? largeDesktop,
Returns a value based on the current screen type.
If a specific value for the current screen type is provided, it is returned.
Otherwise, it falls back to the nearest smaller screen type, eventually defaulting to mobile.
Implementation
T valueByScreen<T>({
required T mobile,
T? watch,
T? tablet,
T? smallDesktop,
T? desktop,
T? largeDesktop,
}) {
final type = data.screenType;
if (type == ScreenType.watch) {
return watch ?? mobile;
}
if (type == ScreenType.mobile) {
return mobile;
}
if (type == ScreenType.tablet) {
return tablet ?? mobile;
}
if (type == ScreenType.smallDesktop) {
return smallDesktop ?? tablet ?? mobile;
}
if (type == ScreenType.desktop) {
return desktop ?? smallDesktop ?? tablet ?? mobile;
}
return largeDesktop ?? mobile;
}