dart - Flutter-环绕文本

我想随着文本的增长而换行。我搜索并尝试用几乎所有内容进行换行,但文本仍然停留在一行并从屏幕溢出。 有谁知道如何实现这一目标? 非常感谢任何帮助!

Positioned(
    left: position.dx,
    top: position.dy,
    child: new Draggable(
      data: widget.index,
      onDragStarted: widget.setDragging,
      onDraggableCanceled: (velocity, offset) {
        setState(() {
          position = offset;
          widget.secondCallback(offset, widget.index);
          widget.endDragging();
        });
      },
      child: new GestureDetector(
        onTap: () {
          widget.callback(widget.caption, widget.index);
        },
        child: new Text(
            widget.caption.caption,
            style: new TextStyle(
              color: widget.caption.color,
              fontSize: widget.caption.fontSize,
            ),
          ),
      ),
      feedback: new Material(
        type: MaterialType.transparency,
        child: new Text(
          widget.caption.caption,
          style: new TextStyle(
              color: widget.caption.color,
              fontSize: widget.caption.fontSize),
          softWrap: true,
        ),
      ),
    ));

最佳答案

灵活的可以解决问题

new Container(
       child: Row(
         children: <Widget>[
            Flexible(
               child: new Text("A looooooooooooooooooong text"))
                ],
        ));

这是官方文档 https://flutter.dev/docs/development/ui/layout#lay-out-multiple-widgets-vertically-and-horizontally关于如何排列小部件。

请记住,FlexibleExpanded 只能在 ColumnRow 中使用>Flex,因为ParentDataWidget的使用不正确

解决方案不仅仅是灵活

https://stackoverflow.com/questions/51930754/

相关文章:

generics - 为什么有状态的小部件在flutter中定义为两个类?

flutter - Flutter 中 SliverList 与 ListView 的区别

flutter - 如何使用主题通用更改AppBar的文本颜色,FAB的图标颜色?

dart - Flutter - 更改 OutlineInputBorder 的边框颜色

image - 如何在 Flutter 中拉伸(stretch)图像以适合整个背景(100% 高度

flutter - 如何将两个 ListView 放在一个列中?

dart - 如何在 flutter 中创建工具栏搜索 View

flutter - 变量名前的下划线 "_"对 Flutter 意味着什么

dart - 如何更改 textField 下划线颜色?

flutter - 如何在 Flutter 中将图像和文件上传到服务器?