ForScreenSize<T> function
T
ForScreenSize<
T>( - BuildContext context, {
- T? mobile,
- T? tablet,
- T? desktop,
- T? defaultValue,
})
Implementation
T ForScreenSize<T>(
BuildContext context, {
T? mobile,
T? tablet,
T? desktop,
T? defaultValue,
}) {
final layoutInfo = sunny.get<LayoutInfo>(context: context);
switch (layoutInfo.screenType) {
case DeviceScreenType.mobile:
return mobile ?? defaultValue as T;
case DeviceScreenType.tablet:
return tablet ?? desktop ?? defaultValue as T;
case DeviceScreenType.desktop:
return desktop ?? defaultValue as T;
case DeviceScreenType.watch:
return defaultValue as T;
default:
return defaultValue as T;
}
}