DisplayFeatureSubScreen class

Positions child such that it avoids overlapping any DisplayFeature that splits the screen into sub-screens.

A DisplayFeature splits the screen into sub-screens when both these conditions are met:

  • it obstructs the screen, meaning the area it occupies is not 0 or the state is DisplayFeatureState.postureHalfOpened.
  • it is at least as tall as the screen, producing a left and right sub-screen or it is at least as wide as the screen, producing a top and bottom sub-screen

After determining the sub-screens, the closest one to anchorPoint is used to render the content.

If no anchorPoint is provided, then Directionality is used:

If no anchorPoint is provided, and there is no Directionality ancestor widget in the tree, then the widget asserts during build in debug mode.

Similarly to SafeArea, this widget assumes there is no added padding between it and the first MediaQuery ancestor. The child is wrapped in a new MediaQuery instance containing the DisplayFeatures that exist in the selected sub-screen, with coordinates relative to the sub-screen. Padding is also adjusted to zero out any sides that were avoided by this widget.

See also:



DisplayFeatureSubScreen({Key? key, Offset? anchorPoint, required Widget child})
Creates a widget that positions its child so that it avoids display features.


anchorPoint Offset?
The anchor point used to pick the closest sub-screen.
child Widget
The widget below this widget in the tree.
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
runtimeType Type
A representation of the runtime type of the object.
no setterinherited


build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
toStringShort() String
A short, textual description of this widget.


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

Static Methods

avoidBounds(MediaQueryData mediaQuery) Iterable<Rect>
Returns the areas of the screen that are obstructed by display features.
subScreensInBounds(Rect wantedBounds, Iterable<Rect> avoidBounds) Iterable<Rect>
Returns sub-screens resulted by dividing wantedBounds along items of avoidBounds that are at least as tall or as wide.