Flutter - テキストの折り返し 質問する

Flutter - テキストの折り返し 質問する

テキストが長くなるにつれてテキストを折り返したいです。検索して、ほぼすべての折り返しを試しましたが、テキストは 1 行のままで、画面からはみ出てしまいます。これを実現する方法をご存知の方はいらっしゃいますか? ご協力いただければ幸いです。

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,
        ),
      ),
    ));

ベストアンサー1

うまくFlexibleいく

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

これは公式ドキュメントですhttps://flutter.dev/docs/development/ui/layout#lay-out-multiple-widgets-vertical-and-horizo​​ntallyウィジェットを配置する方法について説明します。

Flexibleまた、 は、の理由により、、またはExpanded内でのみ使用する必要があることに注意してください。ColumnRowFlexIncorrect use of ParentDataWidget

解決策は単なるFlexible

おすすめ記事