getForBreakpoint method

D? getForBreakpoint(
  1. Breakpoints breakpoint
)

Returns the data for the breakpoint. This is a mobile-first approach, where if there is no data for the breakpoint, the data of the previous (smaller) non-null breakpoint will be used.

Implementation

D? getForBreakpoint(Breakpoints breakpoint) {
  // Start from the breakpoint and go down until a data is not null.
  if (breakpoint == Breakpoints.xl && xl != null) return xl;
  if (breakpoint >= Breakpoints.lg && lg != null) return lg;
  if (breakpoint >= Breakpoints.md && md != null) return md;
  if (breakpoint >= Breakpoints.sm && sm != null) return sm;
  if (breakpoint >= Breakpoints.xs && xs != null) return xs;
  return null;
}