美文网首页
flutter 文本widget

flutter 文本widget

作者: CaptainRoy | 来源:发表于2019-10-10 14:41 被阅读0次
  • 文本


    文本
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,
    );
  }
}

相关文章

网友评论

      本文标题:flutter 文本widget

      本文链接:https://www.haomeiwen.com/subject/xctapctx.html