getParagraphDirection function

TextDirection getParagraphDirection(
  1. String text
)

Returns the TextDirection of the text based on its first non-whitespace character.

The default value is TextDirection.ltr for any character that is not from an RTL language.

Implementation

TextDirection getParagraphDirection(String text) {
  text = text.trim();

  if (text.isNotEmpty && _rtlRegExp.hasMatch(String.fromCharCode(text.runes.first))) {
    return TextDirection.rtl;
  } else {
    return TextDirection.ltr;
  }
}