如何在Flutter中为小部件添加边框? [英] How can I add a border to a widget in Flutter?

查看:68
本文介绍了如何在Flutter中为小部件添加边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Flutter,我想为小部件(在本例中为文本"小部件)添加边框.

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

我尝试了TextStyle和Text,但没有看到如何添加边框.

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

推荐答案

您可以将 TextField 作为 child 添加到 Container 具有具有 border 属性的 BoxDecoration :

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

这篇关于如何在Flutter中为小部件添加边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆