containsRTLCharacters static method

bool containsRTLCharacters(
  1. String text
)

Detects if the given text contains RTL characters

Implementation

static bool containsRTLCharacters(String text) {
  if (text.isEmpty) return false;

  for (int i = 0; i < text.length; i++) {
    int codeUnit = text.codeUnitAt(i);

    for (List<int> range in rtlUnicodeRanges) {
      if (codeUnit >= range[0] && codeUnit <= range[1]) {
        return true;
      }
    }
  }
  return false;
}