flutter 如何在一个文本字段中制作不同的字体大小

dced5bon  于 2022-12-05  发布在  Flutter
关注(0)|答案(1)|浏览(181)

如何使不同的字体大小在一个文本字段?我想使1个文本字段,但不同的字符输入有不同的字体大小/颜色/样式等。
[AABBaS 好的,伙计**!**]

i5desfxk

i5desfxk1#

你可以试试这个

RichText(
 text: TextSpan(
 text: 'Hello ',
 style: DefaultTextStyle.of(context).style,
 children: const <TextSpan>[
  TextSpan(text: 'bold', style: TextStyle(fontWeight: FontWeight.bold)),
  TextSpan(text: ' world!'),
  ],
 ),
)

来源:https://api.flutter.dev/flutter/widgets/RichText-class.html

相关问题