gpt4 book ai didi

dart - 如何在 flutter 中为 PhysicalModel 添加波纹效果

转载 作者:IT王子 更新时间:2023-10-29 06:40:25 26 4
gpt4 key购买 nike

我正在尝试创建一个登录按钮,按下它时会显示动画。但是当点击按钮(在 PhysicalModel 上)时,涟漪效应只显示在登录文本上,而不是完全在物理模型上。如何为 PhysicalModel 添加涟漪效果或从 MaterialButton 移除涟漪效果?

PhysicalModel(
color: Colors.teal,
borderRadius: BorderRadius.circular(50.0),
child: MaterialButton(
key: _globalKey,
child: Text("Login"),
onPressed: () {
setState(() {
if (_state == 0) {
animateButton();
}
});
},
elevation: 4.0,
minWidth: _width,
height: 20.0,
),
)

最佳答案

如果您想移除 MaterialButton 的启动颜色,只需将这些颜色更改为透明即可。

  MaterialButton(
splashColor: Colors.transparent,
highlightColor: Colors.transparent,

如果你想为你的 PhysicalModel 产生链式 react :

    PhysicalModel(
color: Colors.teal,
borderRadius: BorderRadius.circular(50.0),
child: RawMaterialButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50.0)),
padding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 30.0),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
child: Text("Login"),
onPressed: () {
setState(() {});
},
elevation: 4.0,
),
)

关于dart - 如何在 flutter 中为 PhysicalModel 添加波纹效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53755345/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com