在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),
),
),
],
);
}
}

我想把这个输出准确地画出来。非常感谢!

参见输入

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

最新更新