clampDropdownHeightToPreventScreenOverflow function
ClampResult
clampDropdownHeightToPreventScreenOverflow(
{ - required double inversionCheckedAbsoluteDropdownTopPos,
- required double dropdownHeight,
- required double screenHeight,
})
Implementation
ClampResult clampDropdownHeightToPreventScreenOverflow({
/// Make sure that the passed in offset has already gone through the y inversion
/// check.
required double inversionCheckedAbsoluteDropdownTopPos,
required double dropdownHeight,
required double screenHeight,
}) {
final topSubtract = max(0, inversionCheckedAbsoluteDropdownTopPos) -
inversionCheckedAbsoluteDropdownTopPos;
final inversionCheckedAbsoluteDropdownBottomPos =
inversionCheckedAbsoluteDropdownTopPos + dropdownHeight;
final bottomSubtract =
min(screenHeight, inversionCheckedAbsoluteDropdownBottomPos) -
inversionCheckedAbsoluteDropdownBottomPos;
final ySubtract = topSubtract.abs() + bottomSubtract.abs();
final overflowCheckedHeight = dropdownHeight - ySubtract;
return ClampResult(
overflowCheckedHeight: overflowCheckedHeight,
topSubtract: topSubtract,
bottomSubtract: bottomSubtract);
}