Flutter-RichText

2019-12-30  本文已影响0人  梦幽辰

可在一行文字里定义多种样式

class BasicDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return RichText(
      text: TextSpan(
        text: 'ninghao',
        style: TextStyle(
          color: Colors.deepPurpleAccent,
          fontSize: 34,
          fontStyle: FontStyle.italic, // 斜体
          fontWeight: FontWeight.w100, // 文字的粗细
        ),
        children: [
          TextSpan(
            text: '.net',
            style: TextStyle(
              fontSize: 17,
              color: Colors.black
            )
          )
        ]
      ),
    );
  }
}
预览
上一篇 下一篇

猜你喜欢

热点阅读