textDirectionOf function
Maps the panel's published direction to Flutter's TextDirection.
lib/schema/ stays Flutter-free by design, so this mapping lives here,
the one file every screen already imports for
materialPanelStateBuilder, rather than a seventh new import per screen.
A screen's own State.context is an ANCESTOR of the Directionality
withPanelDirection wraps around its build() output, not a descendant
— Directionality.of(that context) reads whatever the host set, not
this wrap, which is exactly the bug review finding 2 (fix round 1)
caught in an early version of the overlay-route fix below. Any screen
method that opens a route (showDialog/showModalBottomSheet/a picker's
builder:) from outside a widget's own build(BuildContext) — where
context genuinely is positioned below the wrap — must resolve the
direction from the schema value directly, via this function, not by
calling Directionality.of(context).
Implementation
TextDirection textDirectionOf(PanelDirection direction) =>
direction == PanelDirection.rtl ? TextDirection.rtl : TextDirection.ltr;