在Flutter中,可以使用FontWeight属性来设置文本的粗细程度。FontWeight属性接受一个FontWeight枚举类型的值,包括以下几种常用的值:
FontWeight.w100 - 超轻FontWeight.w200 - 轻FontWeight.w300 - 较轻FontWeight.w400 - 普通FontWeight.w500 - 中等FontWeight.w600 - 较粗FontWeight.w700 - 粗FontWeight.w800 - 较粗FontWeight.w900 - 超粗例如,如果要将文本设置为粗体字体,可以将fontWeight属性设置为FontWeight.bold,如下所示:
Text( 'Hello, World!', style: TextStyle( fontWeight: FontWeight.bold, ),),除了使用上述常用的值外,也可以通过FontWeight的静态方法来创建自定义的粗细程度,例如:
FontWeight customFontWeight = FontWeight.w500 + 100;Text( 'Hello, World!', style: TextStyle( fontWeight: customFontWeight, ),), 

