flutterdart

flutter contextual text direction


Is it possible to have contextual text direction, that means in current text direction, no matter LRT or RTL the direction sets based on the content of the text

If we have the following code

Column(
  children: <Widget>[
    const Text('English'), // Always LTR
    const Text('فارسی'), // Always RTL
    Text(stringVriableMaybeLtrMaybeRtl), // Based on content, May be LTR may be RTL
  ],
)

As there is asked in comments for mix of both see https://en.wikipedia.org/wiki/Bidirectional_text


Solution

  • I found a solution here https://stackoverflow.com/a/69025915/6447123 that use intl.Bidi.detectRtlDirectionality but may be there is better option