GlobalResponsive class
A global singleton that holds the current ResponsiveData.
This allows accessing responsive metrics without a BuildContext,
enabling num extensions like .w, .h, .fz, .s to work
anywhere in the widget tree (including const widgets).
Design
Scalify assumes a single ScalifyProvider per application. The provider automatically calls update during its lifecycle, keeping this singleton in sync with the current screen metrics.
When to use
Prefer context.responsiveData or ResponsiveBuilder when a
BuildContext is available. Use GlobalResponsive.data only in
scenarios where no context exists (e.g., utility functions, models).
Nested providers
If multiple ScalifyProviders exist in the tree (e.g., inside
AppWidthLimiter), the last one to update wins globally.
This is intentional — the innermost provider reflects the constrained
viewport, which is the correct scaling for its subtree.
However, num extensions outside that subtree will also see the
updated values until the outer provider recalculates.
In practice, this is rarely an issue because AppWidthLimiter only
creates a nested provider when the screen exceeds maxWidth.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- data → ResponsiveData
-
Gets the current globally cached ResponsiveData.
no setter
Static Methods
-
reset(
) → void - Resets the global state. Intended for testing only.
-
update(
ResponsiveData data) → void - Updates the global responsive data. This is called automatically by ScalifyProvider.