expand textfield flutter code example

Example 1: dynamically increase the size of textfield as user types flutter

set the maxLines property of TextField to null. maxLines: null

Example 2: adjust keybaord behaviour in textform field flutter

var _ageController = TextEditingController();var _heightController = TextEditingController();var _weightController = TextEditingController();final FocusNode _ageFocus = FocusNode();  final FocusNode _heightFocus = FocusNode();  final FocusNode _weightFocus = FocusNode();var _mainPartView = Container(  width: 380.0,  height: 240.0,  color: Colors.grey,  child: Column(    children: [      TextFormField(        controller: _ageController,        keyboardType: TextInputType.number,        textInputAction: TextInputAction.next,        focusNode: _ageFocus,        onFieldSubmitted: (term){          _fieldFocusChange(context, _ageFocus, _heightFocus);        },        decoration: InputDecoration(          labelText: 'Age',          hintText: 'Age',          icon: Icon(Icons.person_outline),          fillColor: Colors.white,        ),      ),      TextFormField(        controller: _heightController,        keyboardType: TextInputType.number,        textInputAction: TextInputAction.next,        focusNode: _heightFocus,        onFieldSubmitted: (term) {          _fieldFocusChange(context, _heightFocus, _weightFocus);        },        decoration: InputDecoration(            labelText: _heightMessage,            hintText: _heightMessage,            icon: Icon(Icons.assessment),            fillColor: Colors.white,        ),      ),      TextFormField(        controller: _weightController,        keyboardType: TextInputType.number,        textInputAction: TextInputAction.done,        focusNode: _weightFocus,        onFieldSubmitted: (value){          _weightFocus.unfocus();          _calculator();        },        decoration: InputDecoration(            labelText: _weightMessage,            hintText: _weightMessage,            icon: Icon(Icons.menu),            fillColor: Colors.white        ),      ),      Padding(padding: EdgeInsets.all(4.5)),      Center(        child: RaisedButton(          onPressed: _calculator,          color: Colors.pinkAccent,          child: Text(            'Calculate',            style: TextStyle(fontSize: 16.9),          ),          textColor: Colors.white70,        ),      )    ],  ),);_fieldFocusChange(BuildContext context, FocusNode currentFocus,FocusNode nextFocus) {    currentFocus.unfocus();    FocusScope.of(context).requestFocus(nextFocus);  }

Tags:

Misc Example