没有合适的资源?快使用搜索试试~ 我知道了~
Flutter Text内容居中显示
3 下载量 70 浏览量
2021-01-07
17:07:52
上传
评论
收藏 22KB PDF 举报
温馨提示
试读
2页
通过设置textAlign属性的值为TextAlign.center可以让Text的内容居中 class _MyHomePageState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Row( children: [ Expanded( chil
资源推荐
资源详情
资源评论
Flutter Text内容居中显示内容居中显示
通过设置textAlign属性的值为TextAlign.center可以让Text的内容居中
class _MyHomePageState extends State {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Row(
children: [
Expanded(
child: Text(
'Hello World',
textAlign: TextAlign.center,
)
)
],
)// This trailing comma makes auto-formatting nicer for build methods.
);
}
}
TextAlign是个枚举类型,源码如下,还支持设置文本位于左边、右边等
/// Whether and how to align text horizontally.
// The order of this enum must match the order of the values in RenderStyleConstants.h's ETextAlign.
enum TextAlign {
/// Align the text on the left edge of the container.
left,
/// Align the text on the right edge of the container.
right,
/// Align the text in the center of the container.
center,
/// Stretch lines of text that end with a soft line break to fill the width of
/// the container.
///
/// Lines that end with hard line breaks are aligned towards the [start] edge.
justify,
资源评论
weixin_38617001
- 粉丝: 5
- 资源: 902
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功