swipeRegion function
Where to swipe: screen (already above the keyboard) narrowed to the scrollable's visible clip; falls back to screen when the overlap is too small to swipe in (a thin strip such as a tab bar is enough across the swipe).
Implementation
Rect4 swipeRegion(Rect4 screen, Rect4? clip, {bool horizontal = false}) {
if (clip == null) return screen;
final x = clip.x > screen.x ? clip.x : screen.x;
final y = clip.y > screen.y ? clip.y : screen.y;
final right = (clip.x + clip.w) < (screen.x + screen.w) ? clip.x + clip.w : screen.x + screen.w;
final bottom = (clip.y + clip.h) < (screen.y + screen.h) ? clip.y + clip.h : screen.y + screen.h;
final minWidth = horizontal ? 80 : 24, minHeight = horizontal ? 24 : 80;
if (right - x < minWidth || bottom - y < minHeight) return screen;
return (x: x, y: y, w: right - x, h: bottom - y);
}