How do I add a border to a widget, in Flutter?

I want to add border to a text widget.

In order to add border to a Text Widget, you should wrap it in Container() and add a border under decoration property, the following code snippet will add a border to all edges of the container:

Widget myWidget() {
  return Container(
    margin: const EdgeInsets.all(30.0),
    padding: const EdgeInsets.all(10.0),
    decoration: BoxDecoration(
    border: Border.all(),
    child: Text(
      style: TextStyle(fontSize: 30.0),
1 Like