flutter – 文本意外换行

huangapple go评论69阅读模式
英文:

flutter - Text unintentionally line-broken

问题

我正在使用Flutter开发一个Web应用程序,并遇到了一个原因未知的问题。

这是我的代码:

Padding(
  padding: EdgeInsets.symmetric(horizontal: 20.0),
  child: Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [
      SelectableText(
        "พีเจ เฮ้าส์ เป็นบริษัทโครงการบ้านจัดสรรในประเทศไทย",
        textAlign: TextAlign.start,
        style: GoogleFonts.prompt(),
      ),
      SizedBox(height: 10),
      SelectableText(
        "เราให้บริการลูกค้าด้วยบ้านที่ปลอดภัย สวยงาม และเป็นครอบครัวที่กลมเกลียวกัน\nเราจะแนะนำโครงการที่ซื่อสัตย์บนพื้นฐานของความไว้วางใจ",
        textAlign: TextAlign.start,
        style: GoogleFonts.prompt(),
      ),
      SizedBox(height: 10),
      SelectableText(
        "สร้างอนาคตกับ พีเจ เฮ้าส์",
        textAlign: TextAlign.start,
        style: GoogleFonts.prompt(),
      ),
      SizedBox(height: 50),
    ],
  ),
),

但是当我看到渲染后的屏幕时,文本意外地换行如下图所示。

似乎Text Widget的宽度足够宽,但是却不必要地换行。我还注意到在另一个页面上的泰文文本也有同样的问题,并不一定是这段特定的代码引起的。

如果有人知道解决办法,请帮忙解答。

英文:

I am developing a web application using Flutter. and I have encountered an issue with an unknown cause.

Padding(
  padding: EdgeInsets.symmetric(horizontal: 20.0),
  child: Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: [
      SelectableText(
        "พีเจ เฮ้าส์ เป็นบริษัทโครงการบ้านจัดสรรในประเทศไทย",
        textAlign: TextAlign.start,
        style: GoogleFonts.prompt(),
      ),
      SizedBox(height: 10),
      SelectableText(
        "เราให้บริการลูกค้าด้วยบ้านที่ปลอดภัย สวยงาม และเป็นครอบครัวที่กลมเกลียวกัน\nเราจะแนะนำโครงการที่ซื่อสัตย์บนพื้นฐานของความไว้วางใจ",
        textAlign: TextAlign.start,
        style: GoogleFonts.prompt(),
      ),
      SizedBox(height: 10),
      SelectableText(
        "สร้างอนาคตกับ พีเจ เฮ้าส์",
        textAlign: TextAlign.start,
        style: GoogleFonts.prompt(),
      ),
      SizedBox(height: 50),
    ],
  ),
),

this is my code.
But when I see the rendered screen, the text unintentionally line-breaks as follows.
flutter – 文本意外换行

It seems like the width of the Text Widget is wide enough, but it is unnecessarily line-breaking. and I've noticed the same issue with Thai text on another page, not necessarily this specific code.

If anyone knows a solution, please help.

答案1

得分: 1

这似乎是Chrome的一个bug。在Firefox或Safari上无法重现相同的问题。

请在Flutter仓库上报告这个bug。

flutter – 文本意外换行

英文:

This seems like bug in Chrome. The same issue is not reproducible on Firefox or Safari.

Please raise a bug on Flutter repo regarding this.

flutter – 文本意外换行

huangapple
  • 本文由 发表于 2023年7月27日 16:14:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76777759.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定