Flutter 浅析之 Text Widget

17 篇文章 0 订阅
12 篇文章 2 订阅

技术无止境,只怕不学习啊,Flutter 我们开始吧

Flutter 之路从文本开始 Text

Text文本的居中

class MyApp extends StatelessWidget{

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      title: "Text WidGet", // 标题
      home: Scaffold(
          body: Center(
            child: Text(
              "没事测试一下看看,准备测试了,看看数据是什么结构,是否换行了,拐外了",
            ),
          ),
      ),
    );
  }
}

在这里插入图片描述
TextAlign文本的对齐方式

class MyApp extends StatelessWidget{

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      title: "Text WidGet", // 标题
      home: Scaffold(
          body: Center(
            child: Text(
              "没事测试一下看看,准备测试了,看看数据是什么结构,是否换行了,拐外了",
             textAlign: TextAlign.right ,// right 右对齐, 左对齐 left, 居中 center, 开始的地方 start, 结尾的地方 end
            ),
          ),
      ),
    );
  }
}

在这里插入图片描述
maxLines 行数

class MyApp extends StatelessWidget{

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      title: "Text WidGet", // 标题
      home: Scaffold(
          body: Center(
            child: Text(
              "没事测试一下看看,准备测试了,看看数据是什么结构,是否换行了,拐外了",
              textAlign: TextAlign.right,// right 右对齐, 左对齐 left, 居中 center, 开始的地方 start, 结尾的地方 end
              maxLines: 1, // 行数
            ),
          ),
      ),
    );
  }
}

在这里插入图片描述

TextOverflow

class MyApp extends StatelessWidget{

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      title: "Text WidGet", // 标题
      home: Scaffold(
          body: Center(
            child: Text(
              "没事测试一下看看,准备测试了,看看数据是什么结构,是否换行了,拐外了",
              textAlign: TextAlign.right,// right 右对齐, 左对齐 left, 居中 center, 开始的地方 start, 结尾的地方 end
              maxLines: 1, // 行数
              overflow: TextOverflow.ellipsis, // 渐变fade(从上至下)  ellipsis后面显示...
            ),
          ),
      ),
    );
  }
}

在这里插入图片描述
style 字体样式

class MyApp extends StatelessWidget{

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      title: "Text WidGet", // 标题
      home: Scaffold(
          body: Center(
            child: Text(
              "没事测试一下看看,准备测试了,看看数据是什么结构,是否换行了,拐外了",
              textAlign: TextAlign.right,// right 右对齐, 左对齐 left, 居中 center, 开始的地方 start, 结尾的地方 end
              maxLines: 1, // 行数
              overflow: TextOverflow.ellipsis, // 渐变fade(从上至下)  ellipsis后面显示...
              style: TextStyle( // 字体样式
                fontSize: 25.0,  // 字体大小
                color: Color.fromARGB(255, 255, 125, 125),   // 字体颜色
                decoration: TextDecoration.underline, // 下划线
                decorationStyle: TextDecorationStyle.dashed // 下划线样式  solid 实线 , dashed 虚线
              ),
            ),
          ),
      ),
    );
  }
}

在这里插入图片描述
上面都是比较实用的基础属性,其它的可以自行查询API Text就到这里了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值