Flutter : How to Fix SuffixIcon at the bottom of the Multiline Enable TextField?

Viewed 1138

How to Fix SuffixIcon at the bottom of the Multiline Enable TextField like WhatsApp ?

Here's the Current Scenario :

enter image description here

Here's what I want to acheive :

enter image description here

How can I acheive this ?

Here's the code for the Textfield:

Container(
        width: 350,
        padding: EdgeInsets.symmetric(horizontal: 15),
        decoration: BoxDecoration(
            color: Color(0xffEDEDED),
            borderRadius: BorderRadius.circular(20)),
        child: TextFormField(
          keyboardType: TextInputType.multiline,
          maxLines: null,
          decoration: InputDecoration(
              border: InputBorder.none,
              hintText: 'Type here...',
              hintStyle: TextStyle(color: Color(0xff606060), fontSize: 12),
              suffixIcon: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                mainAxisSize: MainAxisSize.min,
                children: [
                  IconButton(
                      icon: Icon(Icons.camera_alt), onPressed: () {}),
                  IconButton(
                      icon: Icon(Icons.send), onPressed: sendMessage),
                ],
              )),
        ),
      )
3 Answers

Let me know this works.

Container(
              width: 350,
              padding: EdgeInsets.symmetric(horizontal: 15),
              decoration: BoxDecoration(
                  color: Color(0xffEDEDED),
                  borderRadius: BorderRadius.circular(20)),
              child: TextFormField(
                keyboardType: TextInputType.multiline,
                maxLines: null,
                decoration: InputDecoration(
                    border: InputBorder.none,
                    hintText: 'Type here...',
                    hintStyle: TextStyle(color: Color(0xff606060), fontSize: 12),
                    suffixIcon: Column(
                      mainAxisSize: MainAxisSize.max,
                      mainAxisAlignment: MainAxisAlignment.end,
                      children: [
                        Row(
                          crossAxisAlignment: CrossAxisAlignment.end,
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          mainAxisSize: MainAxisSize.min,
                          children: [
                            IconButton(
                                icon: Icon(Icons.camera_alt), onPressed: () {}),
                            IconButton(icon: Icon(Icons.send), onPressed: () {}),
                          ],
                        ),
                      ],
                    )),
              ),
            ),

You can do like following to put send button at bottom of the TextField :

TextFormField(
controller: cnt_msg,
decoration: new InputDecoration(
  suffixIcon: InkWell(
      onTap: () {},
      child: Container(
          width: 50,
          alignment: Alignment.bottomCenter,
          height: 100,
          child: Icon(Icons.send, size: 25))),
  labelText: "Message",
  border: new OutlineInputBorder(
    borderRadius: new BorderRadius.circular(25.0),
    borderSide: new BorderSide(),
  ),
),
maxLines: 5,

)

Should try following solution, That is not proper but you can use this to achieve your targeting UI:

Container(
  width: 350,
  padding: EdgeInsets.symmetric(horizontal: 15),
  decoration: BoxDecoration(color: Color(0xffEDEDED), borderRadius: BorderRadius.circular(20)),
  child: Stack(children: [
    TextFormField(
      keyboardType: TextInputType.multiline,
      maxLines: null,
      decoration: InputDecoration(
        border: InputBorder.none,
        hintText: 'Type here...',
        hintStyle: TextStyle(color: Color(0xff606060), fontSize: 12),
        contentPadding: EdgeInsets.only(right: 90),
      ),
    ),
    Positioned(bottom: 0,right: 0,child: Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      mainAxisSize: MainAxisSize.min,
      children: [
        IconButton(icon: Icon(Icons.camera_alt), onPressed: () {}),
        IconButton(icon: Icon(Icons.send), onPressed: () {}),
      ],))

  ]),
)

enter image description here

You can try this method, when more than one line is added, the container size is increased automatically :

This answer is also right in someway

    Container(
       margin: EdgeInsets.symmetric(horizontal: 16.0),
       decoration: BoxDecoration(
         borderRadius:BorderRadius.all( Radius.circular(30.0)),
         color: Colors.grey
       ),

        child: Column(
          children: [

            TextField(
              keyboardType: TextInputType.multiline,
              maxLines: null,

            ),

            Align(
              alignment: Alignment.bottomCenter,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  Icon(Icons.camera_alt) ,
                  SizedBox(width: 10.0,),
                  Icon(Icons.send) ,
                  SizedBox(width: 10.0,),


                ],
              ),
            ),
            SizedBox(width: 10.0,),

          ],
        ),


      )
Related