Flutter:在主题中指定Button的文本样式

问题描述 投票:0回答:1

是否有可能通过主题影响Button的textStyle?在这种情况下,我希望每个按钮标签都具有特定的fontWeight。ButtonTextTheme仅负责颜色。

我知道我可以为按钮本身的子元素设置样式,但是我希望在主题级别进行样式设置。现在,我需要创建一个自定义的Button Widget,它可以为我执行此操作

flutter button styles material-design
1个回答
0
投票

您喜欢这样:

编辑

MaterialApp(
  title: title,
  theme: ThemeData(
    // Define the default brightness and colors.
    brightness: Brightness.dark,
    primaryColor: Colors.lightBlue[800],
    accentColor: Colors.cyan[600],

    // Define the default font family.
    fontFamily: 'Georgia',

    // Define the default TextTheme. Use this to specify the default
    // text styling for headlines, titles, bodies of text, and more.
    textTheme: TextTheme(
      headline1: TextStyle(fontSize: 72.0, fontWeight: FontWeight.bold),
      headline6: TextStyle(fontSize: 36.0, fontStyle: FontStyle.italic),
      bodyText2: TextStyle(fontSize: 14.0, fontFamily: 'Hind'),
      button:TextStyle(fontSize: 14.0, fontFamily: 'Hind'),
    ),
  )
);

© www.soinside.com 2019 - 2024. All rights reserved.