OverlaySafeArea.of constructor

OverlaySafeArea.of(
  1. BuildContext context, {
  2. BuildContext? surface,
})

Creates an OverlaySafeArea from the given context.

Pass surface when the overlay is inserted somewhere other than context — the insets are then expressed in that surface's coordinates. See OverlaySafeArea.forSurface.

Implementation

factory OverlaySafeArea.of(BuildContext context, {BuildContext? surface}) {
  final padding = MediaQuery.paddingOf(context);
  final safeArea = OverlaySafeArea(
    top: AppBarHeight.maybeOf(context) ?? padding.top,
    bottom: BottomBarHeight.maybeOf(context) ?? padding.bottom,
    left: padding.left,
    right: padding.right,
  );
  return surface == null ? safeArea : safeArea.forSurface(surface);
}