avoidBounds static method

Iterable<Rect> avoidBounds(
  1. MediaQueryData mediaQuery
)

Returns the areas of the screen that are obstructed by display features.

A DisplayFeature obstructs the screen when the area it occupies is not 0 or the state is DisplayFeatureState.postureHalfOpened.

Implementation

static Iterable<Rect> avoidBounds(MediaQueryData mediaQuery) {
  return mediaQuery.displayFeatures
      .where(
        (DisplayFeature d) =>
            d.bounds.shortestSide > 0 || d.state == DisplayFeatureState.postureHalfOpened,
      )
      .map((DisplayFeature d) => d.bounds);
}