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:

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 between minValue and maxValue across the width range [minW, maxW], clamped at both ends — the CSS clamp() equivalent.
isAtLeast(DeviceSize min) bool

Available on BuildContext, provided by the ResponsiveContext extension

Whether the current layout width class is at least min on the ordered scale mobile < 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 most max on the ordered scale mobile < 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.