flutter – 文本意外换行

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

flutter - Text unintentionally line-broken

问题

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

这是我的代码:

  1. Padding(
  2. padding: EdgeInsets.symmetric(horizontal: 20.0),
  3. child: Column(
  4. crossAxisAlignment: CrossAxisAlignment.start,
  5. children: [
  6. SelectableText(
  7. "พีเจ เฮ้าส์ เป็นบริษัทโครงการบ้านจัดสรรในประเทศไทย",
  8. textAlign: TextAlign.start,
  9. style: GoogleFonts.prompt(),
  10. ),
  11. SizedBox(height: 10),
  12. SelectableText(
  13. "เราให้บริการลูกค้าด้วยบ้านที่ปลอดภัย สวยงาม และเป็นครอบครัวที่กลมเกลียวกัน\nเราจะแนะนำโครงการที่ซื่อสัตย์บนพื้นฐานของความไว้วางใจ",
  14. textAlign: TextAlign.start,
  15. style: GoogleFonts.prompt(),
  16. ),
  17. SizedBox(height: 10),
  18. SelectableText(
  19. "สร้างอนาคตกับ พีเจ เฮ้าส์",
  20. textAlign: TextAlign.start,
  21. style: GoogleFonts.prompt(),
  22. ),
  23. SizedBox(height: 50),
  24. ],
  25. ),
  26. ),

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

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

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

英文:

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

  1. Padding(
  2. padding: EdgeInsets.symmetric(horizontal: 20.0),
  3. child: Column(
  4. crossAxisAlignment: CrossAxisAlignment.start,
  5. children: [
  6. SelectableText(
  7. "พีเจ เฮ้าส์ เป็นบริษัทโครงการบ้านจัดสรรในประเทศไทย",
  8. textAlign: TextAlign.start,
  9. style: GoogleFonts.prompt(),
  10. ),
  11. SizedBox(height: 10),
  12. SelectableText(
  13. "เราให้บริการลูกค้าด้วยบ้านที่ปลอดภัย สวยงาม และเป็นครอบครัวที่กลมเกลียวกัน\nเราจะแนะนำโครงการที่ซื่อสัตย์บนพื้นฐานของความไว้วางใจ",
  14. textAlign: TextAlign.start,
  15. style: GoogleFonts.prompt(),
  16. ),
  17. SizedBox(height: 10),
  18. SelectableText(
  19. "สร้างอนาคตกับ พีเจ เฮ้าส์",
  20. textAlign: TextAlign.start,
  21. style: GoogleFonts.prompt(),
  22. ),
  23. SizedBox(height: 50),
  24. ],
  25. ),
  26. ),

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:

确定