Flutter web在处理从右到左的语言和HTML渲染器时存在括号问题。

5

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

这是代码(图中显示了RTL的实际情况。文本代码如下):

rtl text with parentheses

这是使用默认渲染器(桌面上的canvaskit)得到的结果,一切听起来都不错。

default renderer

具有HTML渲染器的相同代码:

html renderer

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

added unicode marks before

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

以下是代码文本:

const Text('You have pushed the button this (many) times:'),
const Text('You have pushed the (دکمه) this (many) times:'),
const Text('تعداد (دفعات) فشار دادن دکمه:', textDirection: TextDirection.rtl),
const Text('تعداد (دفعات) فشار (push) دکمه:', textDirection: TextDirection.rtl),

在HTML渲染器中有没有解决问题的方法?


这个问题通过Flutter(https://github.com/flutter/engine/pull/39162)修复了。请使用Flutter v3.7.4或更高版本。 - undefined
1个回答

0
使用这个渲染:
flutter build web --no-sound-null-safety --web-renderer canvaskit

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接