ScreenSizeAdapterScope class

Wraps child with a MediaQuery that reflects the binding's per-view scale, so MediaQuery.sizeOf(context), paddingOf, viewInsetsOf, devicePixelRatioOf, gesture settings, and display-feature bounds are reported in design units rather than the underlying FlutterView's native logical pixels.

Why this exists: the binding only modifies RenderView.configuration via createViewConfigurationFor — that drives layout, but Flutter's MediaQuery.fromView (the one wired up by the View widget) reads view.physicalSize / view.devicePixelRatio straight from FlutterView, which we cannot override. Without this scope, layout in the widget tree is correctly scaled but MediaQuery reports the raw device size, breaking percentage layout, SafeArea insets, and asset-resolution DPR.

Auto-injection: ScreenSizeWidgetsFlutterBinding.wrapWithDefaultView inserts this scope automatically for the implicit (primary) view, so apps started via runApp need no manual wrapping. For multi-view apps that mount additional View widgets via runWidget or nested ViewAnchors, wrap each View's child manually: This same-engine secondary-view path is experimental; validate it with tool/verification/desktop_multi_view.md in the real host.

View(
  view: secondaryView,
  child: ScreenSizeAdapterScope(
    child: ...,
  ),
)

Pass-through behavior (no wrapping applied to MediaQuery) when:

Under the production binding, a resolved view and parent MediaQuery always keep the same wrapper topology. Unregistered views and an effective scale of 1.0 receive the parent data unchanged; retaining the wrapper prevents application state from being recreated when runtime updates cross the identity-scale boundary.

Inheritance

Constructors

ScreenSizeAdapterScope({Key? key, required Widget child})
const

Properties

child → Widget
Subtree to which the scaled MediaQuery applies.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<ScreenSizeAdapterScope>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited