Flutter web 括号问题与rtl语言+html渲染器

nav*_*vid 5 parentheses right-to-left farsi flutter

当包含括号 () 符号(或 <> 符号)的 RTL 语言(波斯语)文本放置在小Text部件中并且我们使用 html 渲染器 ( ) 为 Web 构建时,问题就会出现flutter run --web-renderer html

\n

这是代码(如图所示按原样显示 RTL。文本代码如下):

\n

带括号的 RTL 文本

\n

这是默认渲染器(桌面上的 canvaskit)的结果,一切听起来都很好:

\n

默认渲染器

\n

与 html 渲染器相同的代码:

\n

html渲染器

\n

如果我们在带括号的单词前面添加 RTL/LTR(分别)unicode 标记,我们会得到:

\n

之前添加了 unicode 标记

\n

这显然解决了“push”这个词的问题。

\n

这是文本代码:

\n
const Text(\'You have pushed the button this (many) times:\'),\nconst Text(\'You have pushed the (\xd8\xaf\xda\xa9\xd9\x85\xd9\x87) this (many) times:\'),\nconst Text(\'\xd8\xaa\xd8\xb9\xd8\xaf\xd8\xa7\xd8\xaf (\xd8\xaf\xd9\x81\xd8\xb9\xd8\xa7\xd8\xaa) \xd9\x81\xd8\xb4\xd8\xa7\xd8\xb1 \xd8\xaf\xd8\xa7\xd8\xaf\xd9\x86 \xd8\xaf\xda\xa9\xd9\x85\xd9\x87:\', textDirection: TextDirection.rtl),\nconst Text(\'\xd8\xaa\xd8\xb9\xd8\xaf\xd8\xa7\xd8\xaf (\xd8\xaf\xd9\x81\xd8\xb9\xd8\xa7\xd8\xaa) \xd9\x81\xd8\xb4\xd8\xa7\xd8\xb1 (push) \xd8\xaf\xda\xa9\xd9\x85\xd9\x87:\', textDirection: TextDirection.rtl),\n
Run Code Online (Sandbox Code Playgroud)\n

有没有办法解决html渲染器的问题?

\n

小智 0

使用这个渲染:

flutter build web --no-sound-null-safety --web-renderer canvaskit
Run Code Online (Sandbox Code Playgroud)