3

How can I add a rounded border for only 3 sides of the box? It's giving me errors if i add an "only" per sides if there is a border radius included.

enter image description here

this is my Code

Container(
  padding: const EdgeInsets.all(10.0),
  decoration: BoxDecoration(
    border: Border.all(color:Colors.grey, width: 2.5),
    borderRadius: BorderRadius.circular(13.0),
  ),
  child: child,
)
CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440
A_Bee
  • 101
  • 2
  • 9

2 Answers2

3

I didn't quite get the screenshot but to have border for three sides, say for only left, right and bottom, use:

final borderSide = BorderSide(color: Colors.white, width: 2);

Container(
  decoration: BoxDecoration(
    border: Border(
      left: borderSide,
      right: borderSide,
      bottom: borderSide,
    ),
  ),
  child: child,
)
CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440
  • 2
    You cannot use border radius in this case - will get an exception "A borderRadius can only be given for a uniform Border." – Bitlejuce Do Jul 15 '22 at 11:48
1

simply use .only in place of .circular

Container(
    padding: const EdgeInsets.all(10.0),
    decoration: BoxDecoration(
      border: Border.all(color:Colors.grey, width: 2.5),
      borderRadius: BorderRadius.only(topLeft: Radius.circular(13.0),topRight: Radius.circular(13.0)),
    ),
    child: child,
  )

Similarly you can add bottomLeft and bottomRight in .only

Deepak Lohmod
  • 2,072
  • 2
  • 8
  • 18