我需要在Flutter中去掉这个文本溢出。我该怎么做?

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

i need to remove this text over flow in flutter. how can i do that?

问题

以下是您要翻译的代码部分:

我在`Column`中的`Text`小部件中遇到了错误。

body: Padding(
  padding: const EdgeInsets.all(20),
  child: Column(
    mainAxisAlignment: MainAxisAlignment.spaceAround,
    children: [
      Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: [
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                widget.songModel.displayNameWOExt,  <------- 这里是我的文本
              ),
              Text(
                widget.songModel.artist.toString(),
                overflow: TextOverflow.fade,
              ),
            ],
          ),  
        ],
      ),
    ],
  ),
);

这是我遇到的问题

这是我需要的样子

英文:

I am facing error in the Text widget which is in Column.

  body: Padding(
    padding: const EdgeInsets.all(20),
    child: Column(
      mainAxisAlignment: MainAxisAlignment.spaceAround,
      children: [
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  widget.songModel.displayNameWOExt,  <------- here is my text
                ),
                Text(
                  widget.songModel.artist.toString(),
                  overflow: TextOverflow.fade,
                ),
              ],
            ),  
      ],
    ),   ), );

This is what happened to me

This is what i need look like

答案1

得分: 1

Expanded小部件包裹Row小部件内的Text

Expanded(child: Text(/* 这里是文本*/),
英文:

Wrap the Text that is inside a Row widget with an Expanded widget:

Expanded(child: Text(/* Here the text*/),

答案2

得分: 0

尝试将Text()小部件嵌套在Expanded()小部件内 扩展文档

Expanded是一个小部件,用于扩展Row、Column或Flex的子元素,以使子元素填充可用空间。

英文:

try embedding the Text() widget inside a Expanded() widget expanded documentation

Expanded is a widget that expands a child of a Row, Column, or Flex so that the child fills the available space.

答案3

得分: 0

将文本包裹在容器中,并在此之后为容器指定特定大小,然后使用 overflow: TextOverflow.fade 或 "overflow" 的任何其他属性,因为这些属性只在你为文本字段指定大小时才有效,但你无法为文本字段指定大小,所以请将其包裹在容器中。

英文:

wrap the text with the container and give a specific size to the container after that use overflow: TextOverflow.fade or any other property of "overflow", because these properties only work when you give a size to textfield but you cant give size to textfield so wrap it with container.

huangapple
  • 本文由 发表于 2023年2月8日 19:51:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/75385407.html
匿名

发表评论

匿名网友

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

确定