withPanelDirection function

Widget withPanelDirection(
  1. PanelDirection direction,
  2. Widget child
)

Wraps child in the Directionality direction resolves to, unconditionally — not a host opt-in (design spec, "Flutter").

Every screen wraps its whole returned widget (Scaffold included), not just the body, so the app bar — title alignment, the back button's side — follows the panel's own layout too.

Implementation

Widget withPanelDirection(PanelDirection direction, Widget child) {
  return Directionality(
    textDirection: textDirectionOf(direction),
    child: child,
  );
}