flutter - 在 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),
),
),
],
),
);
}
}
推荐阅读
- redux - Redux 工具包可以从额外的 reducer 访问完整状态
- javascript - clearInterval 不能从 setTimeout 内的间隔工作
- neo4j - 启用远程访问 neo4j 4.2 社区版
- qt - 如何在 Qt/Qmake 中使用 Visual Studio 代码?(苹果系统)
- javascript - 来自全局组件的 Vue/Nuxt 访问函数
- excel - 检查某个文本框是否为空,然后在 VBA 中运行事件
- reactjs - 反应选择没有使用打字稿获取我选择的值
- android - 如何从 CoroutineScope Kotlin 返回一个 int?
- r - 将 3 个模型指标与 ggplot2 进行比较
- vue.js - 单击事件未在 antd 菜单项中触发