resolveUiEdgeAwareBottomOffset function
double
resolveUiEdgeAwareBottomOffset(
- BuildContext context, {
- required double minimum,
- bool reduceSafeArea = true,
Resolves a bottom offset for floating components that intentionally sit near the physical screen edge.
On devices with a home indicator or rounded physical bottom edge, the safe area bottom inset is usually larger than the visually useful gap. This helper infers a conservative device-edge radius from MediaQueryData.viewPadding and lets components sit closer to that edge while preserving a caller-defined minimum.
Implementation
double resolveUiEdgeAwareBottomOffset(
BuildContext context, {
required double minimum,
bool reduceSafeArea = true,
}) {
final bottomInset = MediaQuery.maybePaddingOf(context)?.bottom ?? 0;
final viewBottomInset = MediaQuery.maybeViewPaddingOf(context)?.bottom ?? 0;
if (!reduceSafeArea) {
return math.max(minimum, math.max(bottomInset, viewBottomInset));
}
if (bottomInset <= 0 || viewBottomInset <= 0) return minimum;
final inferredRadius = viewBottomInset.clamp(14.0, 28.0);
return math.max(minimum, bottomInset - inferredRadius);
}