scrollsHorizontally function

bool scrollsHorizontally(
  1. UiNode n
)

Axis of a scrollable: the semantics scroll actions when advertised (scrollLeft/scrollRight only ⇒ horizontal), else the aspect-ratio heuristic (width/height > 1.2).

Implementation

bool scrollsHorizontally(UiNode n) {
  final a = n.actions;
  final h = a.contains('scrollLeft') || a.contains('scrollRight');
  final v = a.contains('scrollUp') || a.contains('scrollDown');
  if (h != v) return h;
  final w = n.bounds.width;
  final ht = n.bounds.height;
  if (w <= 0 || ht <= 0) return false;
  return w / ht > 1.2;
}