flutter

Add border to widget in Flutter

//ADD BORDER TO ALL SIDES
Container(
  decoration: BoxDecoration(
    border: Border.all(
      color: Colors.red,
      width: 3.0,
    ),
  ),
)

//ADD BORDER TO SPECIFIC SIDES
Container(
  decoration: BoxDecoration(
    border: Border(
      left: BorderSide(
        color: Colors.red,
        width: 3.0,
      ),
      top: BorderSide(
        color: Colors.blue,
        width: 3.0,
      ),
    ),
  ),
)

You can easily add a border to a widget in Flutter by using decoration property and passing border property to it. You can add a border to all sides by using Border.all() and for adding border to specific sides of the widget, you can use BorderSide().

Was this helpful?