Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 颤振文本未在行内换行_Flutter_Dart_Text_Row - Fatal编程技术网

Flutter 颤振文本未在行内换行

Flutter 颤振文本未在行内换行,flutter,dart,text,row,Flutter,Dart,Text,Row,我有一个简单的小部件,里面有行和文本。如果文本较长,它应该直接进入下一行,但现在它停留在一行,并给我一个溢出: 这是我的代码: class HintKeyPoint extends StatelessWidget { final String text; const HintKeyPoint({ required this.text, }); @override Widget build(BuildContext context) { return Row

我有一个简单的
小部件
,里面有
文本
。如果
文本
较长,它应该直接进入下一行,但现在它停留在一行,并给我一个
溢出

这是我的代码:

class HintKeyPoint extends StatelessWidget {
  final String text;

  const HintKeyPoint({
    required this.text,
  });
  @override
  Widget build(BuildContext context) {
    return Row(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        SizedBox(
          width: scaleWidth(10),
        ),
        Container(
          height: scaleWidth(16),
          width: scaleWidth(16),
          decoration: BoxDecoration(
              color: AppColors.primaryLight, shape: BoxShape.circle),
        ),
        SizedBox(
          width: scaleWidth(10),
        ),
        Text(
          text,
          style: AppTextStyles.h7,
        ),
      ],
    );
  }
}

为什么
文本
不占用垂直空间?我在这里做错了什么?

用展开的小部件包装文本小部件。

用展开的小部件包装文本小部件。

您需要用展开的小部件包装文本小部件

例如:

Expanded(
    child: Text(
    "lorem10 lorem10 lorem10lorem10lorem10lorem10lorem10 lorem10lorem10lorem10lorem10lorem10 lorem10lorem10lorem10lorem10lorem10 lorem10",
    ),
),

您需要将
文本小部件
包装为
扩展小部件

例如:

Expanded(
    child: Text(
    "lorem10 lorem10 lorem10lorem10lorem10lorem10lorem10 lorem10lorem10lorem10lorem10lorem10 lorem10lorem10lorem10lorem10lorem10 lorem10",
    ),
),

谢谢:)Alex是第一个,所以我给了他正确的答案,但你的答案是一样的,所以谢谢你的帮助没关系:)我只添加了代码,因为有些询问者不懂,更喜欢复制/粘贴谢谢,@Chris;)谢谢:)Alex是第一个,所以我给了他正确的答案,但你的答案是一样的,所以谢谢你的帮助没关系:)我只添加了代码,因为有些询问者不懂,更喜欢复制/粘贴谢谢,@Chris;)