Flutter基础组件 Text

一 文本组件Text

  1. 有序列表第一项
Text('You have11 pushed the button this many times:',
              textAlign: TextAlign.left,
              style: TextStyle(
                fontSize: 40,
                color: Colors.red,
                backgroundColor: Colors.blue,
              ),

二 富文本组件RichText

  RichText(
                text: TextSpan(style: const TextStyle(), children: [
                  TextSpan(
                      text: '这是一个链接',
                      style: const TextStyle(
                        fontSize: 20.0,
                        color: Colors.red,
                      ),
                  )
                ]
                ),
            ), 

2.Text.rich

        Text.rich(
             TextSpan(
children: [
  TextSpan(
    text: "home"
  ),
  TextSpan(
    text: "https:wwww",
    style: TextStyle(
      color: Colors.red,
    ),
  )
]   )),
截屏2023-06-28 10.59.22.png
  1. DefaultTextStyle
     DefaultTextStyle(style: TextStyle(
            color: Colors.red,
            fontSize: 30,
          ), child: Column(
          children: [
            Text('www'),
            Text('ddd'),
            Text('特别',
            style: TextStyle(
              inherit: false,//不继承默认样式
              color: Colors.blue,
              fontSize: 50
            ),
            ),
          ],
          )
      ),
截屏2023-06-28 11.23.22.png
  1. crossAxisAlignment: CrossAxisAlignment.start, // 加入布局 这句话 ,变为右对齐
   DefaultTextStyle(
              style: TextStyle(
            color: Colors.red,
            fontSize: 30,
          ),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start, // 加入布局 这句话 
          children: [
            Text('www'),
            Text('ddd'),
            Text('特别',
            style: TextStyle(
              inherit: false,//不继承默认样式
              color: Colors.blue,
              fontSize: 50
            ),
            ),
          ],
          )
      ),
截屏2023-06-28 11.27.36.png

三 字体

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容