Midhilaj
Midhilaj

Reputation: 4997

How to add a border color to an OutlineButton

How can I add a border color to an OutlineButton? I tried setting a highlightedBorderColor, but it is not working. How can I solve this issue?

This is my code:

 OutlineButton(
   shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
   onPressed:(){},child: Padding(
   padding: const EdgeInsets.all(12),
   child: Text("add to cart",style: TextStyle(color: Colors.red,fontSize: 20),),
    ),highlightedBorderColor: Colors.red,
 ),

Upvotes: 1

Views: 490

Answers (2)

duongdt3
duongdt3

Reputation: 1678

Take a try with it:

      OutlineButton(
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(20),
          ),
          borderSide: BorderSide(color: Colors.pink, width: 1),
          onPressed: () {},
          child: Padding(
            padding: const EdgeInsets.all(12),
            child: Text(
              "add to cart",
              style: TextStyle(color: Colors.red, fontSize: 20),
            ),
          ),
        )

Upvotes: 2

Ibraheem Ahmed
Ibraheem Ahmed

Reputation: 13628

Add the following line to your code:

borderSide: BorderSide(width: 2.0, color: Colors.red),

This should change the border color of your button to red

Upvotes: 2

Related Questions