[英]How can I change the font size differently?
例如,我想將“Hello world”變成“Hello (//bigger than world) world (//smaller than Hello)”,它們在一行中。
我怎樣才能做到這一點? 我可以通過 TextStyle() 在一個 Text() 小部件中給它們不同的字體大小嗎?
您可以像這樣使用RichText
小部件:
RichText(
text: TextSpan(
text: 'Hello ',
style: DefaultTextStyle.of(context).style,
children: <TextSpan>[
TextSpan(text: 'bold', style: TextStyle(fontWeight: FontWeight.bold)),
TextSpan(text: ' world!'),
],
),
)
請根據需要檢查以下代碼。
RichText(
text: TextSpan(
text: 'Hello ',
style: TextStyle(fontSize: 24),
children: <TextSpan>[
TextSpan(
text: 'world!',
style: TextStyle(fontSize: 18),
),
],
),
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.