Search code examples
flutterflutter-layout

Flutter, TextFormField Suffix Widget position like youtube


It seems to have been an issue for a long time, is there still no solution?

If you set suffixIcon: it will automatically center when MaxLines is 3. (so it locates at 2nd line)

However, the downside of this is that the top and bottom padding values are a problem.

Therefore, customizing it is easier to just use suffix: to make it a widget.

but with suffix:

When I do

Container(child:Text("Test button"))....

The button height is completely lengthened (by the length of max lines)

I just want to implement like youtube comment suffix icon

At first, it's in the top right corner, and whenever the line changes, I want the send Icon to go down too. Is there still no way? Flutter?


Solution

  • You can use Row widget with CrossAxisAlignment.end

    Row(
      crossAxisAlignment: CrossAxisAlignment.end,
      children: [
        Expanded(
          child: TextFormField(
            maxLines: 4,
            minLines: 1,
          ),
        ),
        Icon(Icons.abc) // padding more decoration if needed
      ],
    ),