responsiveValueOf<T> method
Returns a value based on the screen type of the given context.
If the screen type is ScreenType.desktop and desktop is null,
the tablet value will be returned. If tablet is also null,
the mobile value will be returned, and so on.
Implementation
T? responsiveValueOf<T>(
BuildContext context, {
T? mobile,
T? tablet,
T? desktop,
T? watch,
}) {
final type = screenTypeOf(context);
switch (type) {
case ScreenType.desktop:
return desktop ?? tablet ?? mobile ?? watch;
case ScreenType.tablet:
return tablet ?? desktop ?? mobile ?? watch;
case ScreenType.phone:
return mobile ?? tablet ?? desktop ?? watch;
case ScreenType.watch:
return watch ?? mobile ?? tablet ?? desktop;
}
}