ResponsiveList<R> function
List<R>
ResponsiveList<R>(
- BuildContext context, {
- ResponsiveExpression<
R> ? mobile, - ResponsiveExpression<
R> ? tablet, - ResponsiveExpression<
R> ? desktop, - ResponsiveListExpression<
R> ? desktops, - ResponsiveListExpression<
R> ? tablets,
Implementation
List<R> ResponsiveList<R>(
BuildContext context, {
ResponsiveExpression<R>? mobile,
ResponsiveExpression<R>? tablet,
ResponsiveExpression<R>? desktop,
ResponsiveListExpression<R>? desktops,
ResponsiveListExpression<R>? tablets,
}) {
if (mobile == null && desktop == null && tablet == null) {
return const [];
}
final layoutInfo = sunny.get<LayoutInfo>(context: context);
switch (layoutInfo.screenType) {
case DeviceScreenType.mobile:
return mobile != null ? [mobile(context)] : const [];
case DeviceScreenType.tablet:
final fn = tablet ?? desktop;
final fns = tablets ?? desktops;
return [
if (fn != null) fn(context),
if (fns != null) ...fns.call(context),
];
case DeviceScreenType.desktop:
return [
if (desktop != null) desktop(context),
if (desktops != null) ...desktops(context)
];
case DeviceScreenType.watch:
return [];
default:
throw "Invalid type: ${layoutInfo.screenType}";
}
}