guardBracketInHtml static method

String guardBracketInHtml(
  1. String str,
  2. [bool? isRtlContext]

Apply bracket guard to str using html span tag. This is to address the problem of messy bracket display that frequently happens in RTL layout. If isRtlContext is true, then we explicitly want to wrap in a span of RTL directionality, regardless of the estimated directionality.


static String guardBracketInHtml(String str, [bool? isRtlContext]) {
  var useRtl = isRtlContext ?? hasAnyRtl(str);
  var matchingBrackets =
  return _guardBracketHelper(str, matchingBrackets,
      '<span dir=${useRtl ? "rtl" : "ltr"}>', '</span>');