FLUTTER

How to add a border to a widget in Flutter?

In Flutter, you can give a border to a Container or an Input TextField inside the BoxDecoration or InputDecoration fields respectively. In this example, we will show you how to add a border, change its thickness, color, radius, and other properties in Flutter.


Adding a border to a Container

Full Border

For a full border, we can use Border.all constructor. Inside Border.all constructor, you can change properties like color and width. You can also change the border-radius using the borderRadius property inside BoxDecoration.


Border Side

BorderSide can be used to give border to selected sides of the Container. Here in this example, we have used left and bottom properties to add a border to the left and bottom of the container. You can customize the border using the color and width properties inside the BorderSide class.


Adding a border to a TextField

Underline Input Border

Border to a TextField can be given inside the InputDecoration class. In this example shown above, we have used an UnderlineInputBorder with color and width properties. Here we have given the border when the input is enabled. For all other cases, we have given the border as none.


Outline Input Border

In this example shown above, we have used an OutlineInputBorder with color and width properties.


Interactive Example