当 FlatButtons 突出显示颜色发生变化时,我想更改 FlatButton 内的 Text 小部件文本的颜色。当用户长时间按下按钮时,FlatButton 的高亮颜色会发生变化。这是我拥有的按钮的示例代码:
class DefaultButton extends StatelessWidget {
const DefaultButton({
Key key,
this.text,
this.press,
this.buttonColor = primaryColor,
}) : super(key: key);
final String text;
final Function press;
final Color buttonColor;
@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
height: 50,
child: FlatButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)),
highlightColor: Colors.yellow,
color: buttonColor,
onPressed: press,
child: Text(
text,
style: TextStyle(
fontFamily: primaryFontFamily,
fontWeight: FontWeight.w400,
fontSize: 20,
color: primaryColor,
),
),
),
);
}
}
实现这一目标的最佳方法是什么?谢谢!