Flutter 颤振:如何将文本的行高属性设置为主题数据

Flutter 颤振:如何将文本的行高属性设置为主题数据,flutter,Flutter,如何在主题数据内全局设置行高 theme: ThemeData( brightness: Brightness.light, accentColor: myAccentColor, primaryColor: myPrimaryColor, fontFamily: 'Ubuntu', buttonTheme: ThemeData.light().buttonTheme.copyWith( buttonC

如何在
主题数据
内全局设置行高

theme: ThemeData(
       brightness: Brightness.light,
       accentColor: myAccentColor,
       primaryColor: myPrimaryColor,
       fontFamily: 'Ubuntu',
       buttonTheme: ThemeData.light().buttonTheme.copyWith(
            buttonColor: myPrimaryColor,
            textTheme: ButtonTextTheme.primary,
            shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(5)),
       ),
       scaffoldBackgroundColor: myBackgroundWhite,
       cardColor: myBackgroundWhite,
       textSelectionColor: myGreyTextColor,
       cursorColor: myAccentColor,
       cupertinoOverrideTheme: CupertinoThemeData(
          primaryColor: myAccentColor,
       ),
       errorColor: myErrorColorRed,
)

我们无法直接从
主题数据
设置
行高
(属性名称:
高度

处理文字样式的最佳实践是使用材质类型系统准则。请参见中的“材质文字比例:现代化颤振文字主题化”一节

因此,在全局
主题数据上,您可以使用

theme: ThemeData(
          brightness: Brightness.light,
          accentColor: flujoAccentColor,
          primaryColor: flujoPrimaryColor,
          fontFamily: 'FiraSans',
          textTheme: TextTheme(
              headline5: TextStyle(
                fontSize: 24.0,
                fontWeight: FontWeight.w700,
                fontStyle: FontStyle.normal,
              ),
              bodyText1: TextStyle(
                fontSize: 16.0,
                fontStyle: FontStyle.normal,
                letterSpacing: 0.5,
              ),
              bodyText2: TextStyle(
                fontSize: 14.0,
                fontStyle: FontStyle.normal,
                letterSpacing: 0.25,
                height: 1.5,
              ),
              subtitle1: TextStyle(
                fontSize: 16.0,
                fontStyle: FontStyle.normal,
                letterSpacing: 0.15,
              ),
              subtitle2: TextStyle(
                fontSize: 14,
                fontWeight: FontWeight.w400,
                fontStyle: FontStyle.normal,
              ),
              caption: TextStyle(
                fontSize: 12,
                fontWeight: FontWeight.w400,
                fontStyle: FontStyle.normal,
              ),
              overline: TextStyle(
                fontSize: 10,
                fontWeight: FontWeight.w400,
                letterSpacing: 0.25,
                height: 1.5,
                fontStyle: FontStyle.normal,
              )),

像这样,在
文本
小部件上,像这样应用它:

Text(
    "Hello world!",
     style: Theme.of(context).textTheme.bodyText1.copyWith(color: Colors.teal,),
);