How to add a border to a widget in Flutter?

后端 未结 7 622
别那么骄傲
别那么骄傲 2020-11-30 18:38

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.

7条回答
  •  無奈伤痛
    2020-11-30 19:41

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

    new 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"),
    )
    

提交回复
热议问题