getEffectiveTextDirection method

  1. @protected
TextDirection? getEffectiveTextDirection(
  1. BuildContext context
)

The value to pass to RenderBoxyFlex.textDirection.

This value is derived from the textDirection property and the ambient Directionality. The value is null if there is no need to specify the text direction. In practice there's always a need to specify the direction except for vertical flexes (e.g. Columns) whose crossAxisAlignment is not dependent on the text direction (not start or end). In particular, a Row always needs a text direction because the text direction controls its layout order. (For Columns, the layout order is controlled by verticalDirection, which is always specified as it does not depend on an inherited widget and defaults to VerticalDirection.down.)

This method exists so that subclasses of Flex that create their own render objects that are derived from RenderBoxyFlex can do so and still use the logic for providing a text direction only when it is necessary.

Implementation

@protected
TextDirection? getEffectiveTextDirection(BuildContext context) {
  return textDirection ?? Directionality.of(context);
}