Flutter Widget之Text

Widget:https://flutter.io/docs/development/ui/widgets
Text:https://docs.flutter.io/flutter/widgets/Text-class.html

import 'package:flutter/material.dart';

class TextDemoPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => new _TextDemoPageState();
}

class _TextDemoPageState extends State<TextDemoPage> {
  String _name = 'Joe.Ye';

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(title: new Text('Text Page Demo'),),
      body: Center(
        child: Column(
          children: <Widget>[
            Text(
              'Hello, $_name! How are you?',
              textAlign: TextAlign.center,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(fontWeight: FontWeight.bold),
            ),
            const Text.rich(
              TextSpan(
                text: 'Hello', // default text style
                children: <TextSpan>[
                  TextSpan(text: ' beautiful ', style: TextStyle(fontStyle: FontStyle.italic)),
                  TextSpan(text: 'world', style: TextStyle(fontWeight: FontWeight.bold)),
                ],
              ),
            )
          ],
        )
      ),
    );
  }
}

版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/16/flutter-widget-text/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
海报
Flutter Widget之Text
Widget:https://flutter.io/docs/development/ui/widgets Text:https://docs.flutter.io/flutter/widgets/Text-class.html import 'package:flutter/m……
<<上一篇
下一篇>>
文章目录
关闭
目 录