自从 Flutter 弃用 FlatButton 以来,当用户按下按钮时,我无法再使用splashColor 和highlightColor 属性来设置按钮的颜色。现在我必须使用新按钮之一,例如下面的 TextButton,但我还没有找到任何具有以下功能的按钮样式:当用户按下按钮时,背景颜色不会产生波纹效果。
TextButton(
style: ButtonStyle(
overlayColor: MaterialStateProperty.all(Colors.grey[100]),
),
),
Run Code Online (Sandbox Code Playgroud)
Vic*_*wok 14
较晚回复,您可以使用 ButtonStyle 上的splashFactory 属性。
TextButton(
style: TextButton.styleFrom(
splashFactory: NoSplash.splashFactory
),
),
Run Code Online (Sandbox Code Playgroud)