0
votes

How can I change the height of a container and automatically bring the cursor to the next line a line gets filled ( similar to WhatsApp where we type the message ) in flutter? Here is my code: Positioned( bottom: MediaQuery.of(context).size.height*0.03 , child: Container( width: MediaQuery.of(context).size.width,

          ),
          child: Padding(
            padding: EdgeInsets.symmetric(horizontal: 8.0),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                CircleAvatar(
                  backgroundColor: Colors.white,
                  child: IconButton(
                    onPressed: (){

                    },
                    icon: Icon(Icons.add),
                  ),
                ),
                EditableText(
                  expands: true,
                  maxLines: null,
                  minLines: null,
                  style: kTextStyle.copyWith(fontSize: 18.0),
                  cursorColor: Colors.white,
                  scrollPhysics: AlwaysScrollableScrollPhysics(),
                  enableSuggestions: true,
                  controller: _chattextcontroller,
                  backgroundCursorColor: Colors.grey,
                  focusNode: FocusNode(),

                ),
                Expanded(
                  child: IconButton(
                    onPressed: (){

                    },
                    icon: Icon(Icons.send,
                 ),
                  ),
                )
              ],
            ),
          ),
        ),
      )
1

1 Answers

0
votes

Use an EditableText widget:

EditableText(
    expands: true,
    maxLines: null,
    minLines: null,
    //other required params
),