Flutter textfield that auto expands when text is entered and then starts scrolling the text when a certain height is reached

后端 未结 4 1871
后悔当初
后悔当初 2020-12-14 03:36

I\'ve tried many configurations of the Flutter TextField but can\'t figure out how to build this one.

I\'m looking for a textfield that is a single line initially an

4条回答
  •  悲&欢浪女
    2020-12-14 04:15

    Container(
        child: new ConstrainedBox(
            constraints: BoxConstraints(
                maxHeight: 300.0,
            ),
            child: TextField(
                        maxLines: null,
                    ),
                ),
            ),
        ),
    )
    

    In older Flutter versions it was

    Container(
        child: new ConstrainedBox(
            constraints: BoxConstraints(
                maxHeight: 300.0,
            ),
            child: new Scrollbar(
                child: new SingleChildScrollView(
                    scrollDirection: Axis.vertical,
                    reverse: true,
                    child: new TextField(
                        maxLines: null,
                    ),
                ),
            ),
        ),
    )
    

提交回复
热议问题