ResponsiveContext extension
BuildContext extension exposing the responsive API.
Two groups of members with different reactivity models — see the file header's structure-vs-dimensions split:
- Class-based reads (deviceSize; the exact-match predicates isMobile, isTablet, isDesktop; the ordered-threshold predicates isTabletOrLarger, isTabletOrSmaller, isAtLeast, isAtMost; and responsive) resolve the ResponsiveScope's whole-window class and rebuild only when the class flips. They require a ResponsiveScope ancestor.
- Viewport-width helpers (responsiveByViewportWidth, clampByViewportWidth) read the nearest MediaQuery width at the call site and rebuild per-pixel. They require only a MediaQuery ancestor.
- on
Properties
- deviceSize → DeviceSize
-
Available on BuildContext, provided by the ResponsiveContext extension
The current whole-window DeviceSize, from the enclosing ResponsiveScope.no setter - isDesktop → bool
-
Available on BuildContext, provided by the ResponsiveContext extension
Whether the current layout width class is DeviceSize.desktop.no setter - isMobile → bool
-
Available on BuildContext, provided by the ResponsiveContext extension
Whether the current layout width class is DeviceSize.mobile.no setter - isTablet → bool
-
Available on BuildContext, provided by the ResponsiveContext extension
Whether the current layout width class is DeviceSize.tablet.no setter - isTabletOrLarger → bool
-
Available on BuildContext, provided by the ResponsiveContext extension
Whether the current layout width class is DeviceSize.tablet or wider — the ordered "larger than mobile" threshold.no setter - isTabletOrSmaller → bool
-
Available on BuildContext, provided by the ResponsiveContext extension
Whether the current layout width class is DeviceSize.tablet or narrower — the ordered "smaller than desktop" threshold.no setter
Methods
-
clampByViewportWidth(
{required double minValue, required double maxValue, double minW = 360, double maxW = 1200}) → double -
Available on BuildContext, provided by the ResponsiveContext extension
Linearly interpolates betweenminValueandmaxValueacross the width range[minW, maxW], clamped at both ends — the CSSclamp()equivalent. -
isAtLeast(
DeviceSize min) → bool -
Available on BuildContext, provided by the ResponsiveContext extension
Whether the current layout width class is at leastminon the ordered scalemobile < tablet < desktop(inclusive lower bound). -
isAtMost(
DeviceSize max) → bool -
Available on BuildContext, provided by the ResponsiveContext extension
Whether the current layout width class is at mostmaxon the ordered scalemobile < tablet < desktop(inclusive upper bound). -
responsive<
T> ({required T mobile, T? tablet, T? desktop}) → T -
Available on BuildContext, provided by the ResponsiveContext extension
Picks a value by device class, with fallback chaining toward the smaller class. -
responsiveByViewportWidth<
T> ({required Map< double, T> breakpoints, required T fallback}) → T -
Available on BuildContext, provided by the ResponsiveContext extension
Picks a value by call-site viewport width, choosing the highest threshold that is<=the current width.