Flutter-Text Widget 文本组件的使用

TextStyle 类库 :https://docs.flutter.io/flutter/painting/TextStyle-class.html

import 'package:flutter/material.dart';
// 写法1:
void main() => runApp(MyApp());

// 写法2:
// void main() {
//   runApp(MyApp())
// }

class MyApp extends StatelessWidget{
  @override
  Widget build(BuildContext context){
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        // 头部导航
        appBar: AppBar(
          title: Text('welcome to flutter')
        ),
        // 主内容
        body: Center(
          child: Text(
            'Hello Worfsfsd -s -n -fdfsdfsffsfdadaadffdsfddfgddgddgdfgdfgfddgdfgdfgdfgdfgdfgdfgdfgfdfgdgdgdg',
            textAlign: TextAlign.start, // 文本对齐方式:center left right start end 
            maxLines: 1, // 设置最多显示的行数
            overflow: TextOverflow.ellipsis, // 设置文本溢出省略号:clip ellipsis fade 
            style: TextStyle(
              fontSize: 25.0, // 字体大小
              color:Color.fromARGB(255, 255, 125, 125), //字体颜色
              decoration: TextDecoration.underline, // 下划线
            ),
          ),
        ),
      ),
    );
  } 

}

猜你喜欢

转载自blog.csdn.net/Amo__/article/details/90202515
今日推荐