Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add a border to a widget in Flutter?

I'm using Flutter and I'd like to add a border to a widget (in this case, a Text widget).

I tried TextStyle and Text, but I didn't see how to add a border.

like image 562
Seth Ladd Avatar asked Nov 21 '17 21:11

Seth Ladd


People also ask

How do you create a border in Flutter?

Steps to add border to container in Flutter:Step 1: Go to the Container in which you want to add a border. Step 2: Add the decoration parameter and assign the BoxDecoration class. Inside the BoxDecoration add the parameter border and set it to Border. all().

How do you use the border property in Flutter?

Flutter – Change Container Border's Color & Width To change the color and width of Container's border, use its decoration property. Set decoration property with BoxDecoration() object. Set the border property of BoxDecoration() object, with required color and width as per your applications specifications.


1 Answers

You can add the Text as a child to a Container that has a BoxDecoration with border property:

enter image description here

Container(   margin: const EdgeInsets.all(15.0),   padding: const EdgeInsets.all(3.0),   decoration: BoxDecoration(     border: Border.all(color: Colors.blueAccent)   ),   child: Text('My Awesome Border'), ) 
like image 189
Shady Aziza Avatar answered Sep 30 '22 16:09

Shady Aziza