在Flutter中,可以使用FontWeight屬性來設(shè)置文本的粗細(xì)程度。FontWeight屬性接受一個FontWeight枚舉類型的值,包括以下幾種常用的值:
例如,如果要將文本設(shè)置為粗體字體,可以將fontWeight屬性設(shè)置為FontWeight.bold,如下所示:
Text(
'Hello, World!',
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
除了使用上述常用的值外,也可以通過FontWeight的靜態(tài)方法來創(chuàng)建自定義的粗細(xì)程度,例如:
FontWeight customFontWeight = FontWeight.w500 + 100;
Text(
'Hello, World!',
style: TextStyle(
fontWeight: customFontWeight,
),
),