Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In flutter, how to add an outline button that look like a text field with underline?

In flutter, how to add an outline button that look like a text field with underline? I only need a bottom underline.

           OutlineButton(
              color: Theme.of(context).buttonColor,
              textColor: Theme.of(context).textTheme.bodyText1.color,
              // disabledColor: Colors.grey,
              disabledTextColor: Colors.black,
              borderSide: (),
              onPressed: () {

              },
          child: Center(
            child: Text(
              "No Reminder",
              textAlign: TextAlign.center,
              style: TextStyle(fontSize: 18.0),
            ),
          ),
            )
like image 913
phongyewtong Avatar asked Oct 11 '25 13:10

phongyewtong


2 Answers

GestureDetector(
  onTap: () => print('tapped'),
  child: Container(
    // optional
    padding: const EdgeInsets.only(bottom: 1.0),
      decoration: BoxDecoration(
        border: Border(
          bottom: BorderSide(
            width: 2.0, color: Colors.lightBlue.shade900))),
    child: Text('button')),
)

I don't know how it would turn out, but I hope it helps to give you idea to reach your need

like image 172
Federick Jonathan Avatar answered Oct 14 '25 10:10

Federick Jonathan


If I understand your question correctly, you just need to add decoration property of the text and pass TextDecoration.underline to it, to achieve the bottom underline. Working sample code below:

body: Center(
        child: OutlineButton(
              color: Theme.of(context).buttonColor,
              textColor: Theme.of(context).textTheme.bodyText1.color,
              // disabledColor: Colors.grey,
              disabledTextColor: Colors.black,
            //  borderSide: (),
              onPressed: () {

              },
          child: Center(
            child: Text(
              "No Reminder",
              textAlign: TextAlign.center,
              style: TextStyle(fontSize: 18.0, decoration: TextDecoration.underline),
            ),
          ),
            )
      ),

enter image description here

Hope this answers your question.

like image 40
Darshan Avatar answered Oct 14 '25 12:10

Darshan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!