show method

Widget show({
  1. required Widget child,
  2. bool showOnXs = true,
  3. bool showOnSm = true,
  4. bool showOnMd = true,
  5. bool showOnLg = true,
  6. bool showOnXl = true,
  7. bool showOnXxl = true,
  8. Widget? fallback,
})

Conditional rendering based on breakpoint

Shows child only when the condition is met based on breakpoint. Returns fallback widget when condition is not met.

Implementation

Widget show({
  required Widget child,
  bool showOnXs = true,
  bool showOnSm = true,
  bool showOnMd = true,
  bool showOnLg = true,
  bool showOnXl = true,
  bool showOnXxl = true,
  Widget? fallback,
}) {
  final shouldShow = value<bool>(
    xs: showOnXs,
    sm: showOnSm,
    md: showOnMd,
    lg: showOnLg,
    xl: showOnXl,
    xxl: showOnXxl,
    fallback: true,
  );

  return shouldShow ? child : (fallback ?? const SizedBox.shrink());
}