Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何在声明后添加到主题数据变量?_Flutter_Dart - Fatal编程技术网

Flutter 如何在声明后添加到主题数据变量?

Flutter 如何在声明后添加到主题数据变量?,flutter,dart,Flutter,Dart,我有一个独特的情况,如果我可以在声明后向一个主题数据变量添加一个属性,这将节省我很多时间 当前我的主题数据在themes.dart文件中声明: ThemeData lightTheme() { return ThemeData( scaffoldBackgroundColor: Colors.white, fontFamily: "Open Sans", appBarTheme: appBarTheme(), textTheme: text

我有一个独特的情况,如果我可以在声明后向一个主题数据变量添加一个属性,这将节省我很多时间

当前我的主题数据在themes.dart文件中声明:

ThemeData lightTheme() {
  return ThemeData(
    scaffoldBackgroundColor: Colors.white,
    fontFamily: "Open Sans",
    appBarTheme: appBarTheme(),
    textTheme: textTheme(),
    inputDecorationTheme: inputDecorationTheme(),
    visualDensity: VisualDensity.adaptivePlatformDensity,
  );
}

TextTheme textTheme() {
  return TextTheme(
      headline1: TextStyle(
          color: Color(0xFF000000),
          //fontSize: getProportionateScreenWidth(25) I would like to declare this in a different file
          fontWeight: FontWeight.normal),
  )
}
ThemeData稍后在典型主题:lightTheme()的main.dart中用作MaterialApp属性

然后,我想更改body.dart文件中使用headline1 TextTheme的headline1 TextTheme的字体大小:

Text(
  'Hello,',
  textAlign: TextAlign.left,
  style: Theme.of(context).textTheme.headline1, //I want to add a line for fontSize here 
),
我该怎么做?非常感谢您的帮助:)

使用
.copyWith()
作为:


style:Theme.of(context.textTheme.headline1.copyWith(fontSize:17)

正是我想要的,非常感谢:)很高兴帮助你。:)