Flutter主题FlatButton在ButtonBar中的textColor

时间:2018-10-28 19:48:01

标签: flutter themes flutter-layout

将Flutter升级到版本后: [✓] Flutter(频道主版,v0.10.2-pre.82)

primaryColor从我的FlatButton中消失了。

小部件:

new ButtonTheme.bar(
        // make buttons use the appropriate styles for cards

        child: new ButtonBar(
          children: <Widget>[
            new FlatButton(
              child: const Text('DISMISS'),
              onPressed: () {/* ... */},
            ),
            new FlatButton(
              child: const Text('LEARN MORE'),
              onPressed: () {/* ... */},
            ),
          ],
        ),
      ),

主题:

final originalTextTheme = ThemeData.light().textTheme;
final originalButtonTheme = ThemeData.light().buttonTheme;    
final originalBody1 = originalTextTheme.body1;

    return ThemeData.light().copyWith(
        primaryColor: Colors.green[700],
        accentColor: Colors.green[500],
        buttonColor: Colors.grey[800],
        buttonTheme: originalButtonTheme,
        textTheme: originalTextTheme.copyWith(
            body1:
                originalBody1.copyWith(decorationColor: Colors.transparent))); 

如何为FlatButtons的textColor设置主题?

1 个答案:

答案 0 :(得分:0)

如果您希望FlatButton的{​​{1}}与textColor相同,则还需要将ThemeData.primaryColor设置为相同的值。

ColorScheme.primary