繁体   English   中英

在 Flutter 上添加两列文本

[英]Adding two column of text on 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),
          ),
        ),
      ],
    );
  }
}

我想在图片中得到这个 output。 非常感谢!

见输入

您需要使用容器提供蓝色背景,然后使用 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),
          ),
        ),
      ],
    ),

);
  }

}

这就像你的形象......

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

我希望这可以帮助你...

我希望这回答了你的问题

class Body extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.blue,
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
           // first text
            Text('Hello', style: TextStyle(fontSize: 15, color: Colors.white)),
           // second text
            Text('Izabella',
                style: TextStyle(fontSize: 25, color: Colors.white)),
          ],
        ),
      ),
    );
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM