scrollToTop function
void
scrollToTop({})
Scrolls viewport to the top.
- If
fixSafariIOS
istrue
it will detect Safari on iOS (isSafariIOS) and will usey
as1
(not0
) to avoid a bug with direct scroll to0
, wheresmooth
is ignored and the viewport position is vertically shifted even atscrollX == 0
. Bug still present on iOS 16.4 (latest version on current date). - See scrollTo.
Implementation
void scrollToTop(
{bool smooth = true,
int y = 0,
bool fixSafariIOS = false,
int? delayMs,
Object? scrollable}) {
if (fixSafariIOS && y == 0 && isSafariIOS()) {
y = 1;
}
scrollTo(window.scrollX, y,
smooth: smooth, delayMs: delayMs, scrollable: scrollable);
}