flutter 文本widget

2019-10-10  本文已影响0人  CaptainRoy
class MyHomeBody extends StatelessWidget {
    @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Text(
        "《定风波》 苏轼 \n莫听穿林打叶声,何妨吟啸且徐行。\n竹杖芒鞋轻胜马,谁怕?一蓑烟雨任平生。",
        textAlign: TextAlign.center,
        maxLines: 3,
        overflow: TextOverflow.ellipsis,
        style: TextStyle(
            fontSize: 18,
            color: Colors.purple,
        ),
    );
  }
}
class MyHomeBody extends StatelessWidget {
    @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Text.rich(
        TextSpan(
            children: [
                TextSpan(text: "《定风波》",style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold,color: Colors.black)),
                TextSpan(text: "苏轼",style: TextStyle(fontSize: 18,color: Colors.red)),
                TextSpan(text: "\n莫听穿林打叶声,何妨吟啸且徐行。\n竹杖芒鞋轻胜马,谁怕?一蓑烟雨任平生。"),
            ],
        ),
        style: TextStyle(fontSize: 20,color: Colors.purple),
        textAlign: TextAlign.center,
    );
  }
}
上一篇 下一篇

猜你喜欢

热点阅读