DeviceRegistry class
Centralized registry for managing device-specific settings in the design system.
Purpose:
- Allows the host project to register a custom reference width.
- Works seamlessly with DeviceHelper to ensure UI elements scale properly.
Usage:
// Register a reference width once at app startup
DeviceRegistry.registerReferenceWidth(440.0);
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
- isTvMode → bool
-
Whether TV scaling is active.
no setter
- referenceWidth → double
-
Retrieves the registered reference width.
no setter
- tvDesignHeight → double
-
Design height used by TV scaling.
no setter
Static Methods
-
registerReferenceWidth(
double width) → void - Registers a custom reference width to be used for scaling calculations.
-
registerTvMode(
{double designHeight = 1080.0}) → void -
Switches DeviceHelper.getScalingFactor to TV scaling: the factor becomes
the screen's shortest side divided by
designHeight(default 1080), so a layout drawn for a 1920x1080 screen looks the same on any TV resolution. The result is clamped to 0.5 - 2.0. Off by default; call once at startup when the app runs on a TV. -
resetTvMode(
) → void - Turns TV scaling off again (phones and tablets use the normal rules).