首页 > 解决方案 > 在 Flutter 上添加两列文本

问题描述

我想在我的主页中添加两行不同类型的文本。但是当我添加另一个文本小部件时,什么也没有发生。这是我的代码;

class Body extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        Center(
          child: Text(
            "Hello",
            style: TextStyle(fontSize: 28, color: Colors.white),
          ),
        ),
      ],
    );
  }
}

我想准确地得到这个输出。非常感谢!

见输入

标签: fluttertextwidget

解决方案


您需要使用容器提供蓝色背景,然后使用 Column 和 Text 小部件。您正在使用文本颜色为白色,背景颜色也为白色,这将如何显示...

class Body extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.blue,
      child: Column(
      children: <Widget>[
        Center(
          child: Text(
            "Hello",
            style: TextStyle(fontSize: 28, color: Colors.white),
          ),
        ),
       Center(
          child: Text(
            "Izabella",
            style: TextStyle(fontSize: 38, color: Colors.white),
          ),
        ),
      ],
    ),

);
  }

}

推荐阅读