Flutter 如何在Flatter中创建重音按钮?

Flutter 如何在Flatter中创建重音按钮?,flutter,Flutter,我正试图在flatter中创建一个凸起的“重音”按钮,即背景颜色与应用程序的重音主题颜色相同。这是我的密码: new RaisedButton( onPressed: _signInPressed, child: new Text('Sign in with Google'), color: Theme.of(context).accentColor, ) 问题是文本颜色仍然是黑色。如何将文本颜色设置为像AppBar中那样的白色?目前没有官方方法获取重音按钮。 不过,你可以让自己拥

我正试图在flatter中创建一个凸起的“重音”按钮,即背景颜色与应用程序的重音主题颜色相同。这是我的密码:

new RaisedButton(
  onPressed: _signInPressed,
  child: new Text('Sign in with Google'),
  color: Theme.of(context).accentColor,
)

问题是文本颜色仍然是黑色。如何将文本颜色设置为像AppBar中那样的白色?

目前没有官方方法获取重音按钮。 不过,你可以让自己拥有:

class AccentButton extends StatelessWidget {
  final VoidCallback onPressed;
  final Widget child;

  const AccentButton({this.child, this.onPressed, Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);

    return RaisedButton(
      onPressed: onPressed,
      child: child,
      textColor: theme.accentTextTheme.button.color,
      highlightColor: theme.accentColor,
      color: theme.accentColor,
    );
  }
}

目前还没有官方的方法来获取重音按钮。 不过,你可以让自己拥有:

class AccentButton extends StatelessWidget {
  final VoidCallback onPressed;
  final Widget child;

  const AccentButton({this.child, this.onPressed, Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);

    return RaisedButton(
      onPressed: onPressed,
      child: child,
      textColor: theme.accentTextTheme.button.color,
      highlightColor: theme.accentColor,
      color: theme.accentColor,
    );
  }
}

对我来说,它创建了一个带有灰色背景和蓝色文本的按钮(在具有默认材质主题的应用程序中)。我要找的是一个带有蓝色背景和白色文本的按钮,这就是你应该让你的按钮使用重音主题(或者直接使用textTheme`property)的方式。但它们的实施似乎是错误的。在他们的代码中,在任何情况下我们都不会有口音背景这里是为youThanks做的!这就完成了我的工作(尽管我个人使用了“highlightColor:theme.highlightColor”,以便可以看到高光像浮动动作按钮一样“扩散”),创建了一个带有灰色背景和蓝色文本的按钮(在具有默认材质主题的应用程序中)。我要找的是一个带有蓝色背景和白色文本的按钮,这就是你应该让你的按钮使用重音主题(或者直接使用textTheme`property)的方式。但它们的实施似乎是错误的。在他们的代码中,在任何情况下我们都不会有口音背景这里是为youThanks做的!这就完成了(尽管我个人使用了“highlightColor:theme.highlightColor”,以便可以看到高光像浮动动作按钮一样“扩散”)