getOffsetY method
Obtains the y-offset to place the FloatingActionButton based on the Scaffold's layout.
Used by getOffset to compute its y-coordinate.
Implementation
@override
double getOffsetY(ScaffoldPrelayoutGeometry scaffoldGeometry, double adjustment) {
final double contentBottom = scaffoldGeometry.contentBottom;
final double bottomContentHeight = scaffoldGeometry.scaffoldSize.height - contentBottom;
final double bottomSheetHeight = scaffoldGeometry.bottomSheetSize.height;
final double fabHeight = scaffoldGeometry.floatingActionButtonSize.height;
final double snackBarHeight = scaffoldGeometry.snackBarSize.height;
final double safeMargin = math.max(
kFloatingActionButtonMargin,
scaffoldGeometry.minViewPadding.bottom - bottomContentHeight + kFloatingActionButtonMargin,
);
double fabY = contentBottom - fabHeight;
if (snackBarHeight > 0.0) {
fabY =
math.min(fabY, contentBottom - snackBarHeight - fabHeight - kFloatingActionButtonMargin);
}
if (bottomSheetHeight > 0.0) {
fabY = math.min(fabY, contentBottom - bottomSheetHeight - fabHeight / 2.0);
}
return fabY + adjustment;
}