Automatically scroll multiline TextFormField when it extends the maxLines attribute

Our team accomplished this by nesting some existing widgets:

// create the illusion of a beautifully scrolling text box
return new Container(
    color: Colors.gray,
  padding: new EdgeInsets.all(7.0),

  child: new ConstrainedBox(
    constraints: new BoxConstraints(
      minWidth: _contextWidth(),
      maxWidth: _contextWidth(),
      minHeight: AppMeasurements.isLandscapePhone(context) ? 25.0 : 25.0,
      maxHeight: 55.0,
    ),

    child: new SingleChildScrollView(
      scrollDirection: Axis.vertical,
      reverse: true,

        // here's the actual text box
        child: new TextField(
          keyboardType: TextInputType.multiline,
          maxLines: null, //grow automatically
          focusNode: mrFocus,
          controller: _textController,
          onSubmitted: currentIsComposing ? _handleSubmitted : null,
          decoration: new InputDecoration.collapsed(
            hintText: ''Please enter a lot of text',
          ),
        ),
        // ends the actual text box

      ),
    ),
  );
}

We had help from Darky to get widget ordering and the correct widgets to make it work.


This appears to be a missing feature in the Flutter Framework, I've filed a bug to get it resolved: https://github.com/flutter/flutter/issues/9365


With the latest flutter 1.20.4, this text field will scroll when it rich the max hight.

       Container(
          constraints: BoxConstraints(maxHeight: 200),
             child: TextField(
                maxLines: null,
                 .......
                )
            )

If you are using the Textfield inside Raw or column wrap it in Expanded widget