Seth Ladd Seth Ladd - 10 months ago 92
Dart Question

How do 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.

Thanks!

Answer Source

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

enter image description here

new Container(
  margin: const EdgeInsets.all(15.0),
  padding: const EdgeInsets.all(3.0),
  decoration: new BoxDecoration(
    border: new Border.all(color: Colors.blueAccent)
  ),
  child: new Text("My Awesome Border"),
)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download