Roc*_*nat 2 flutter flutter-layout
有没有办法完全去除下的阴影RaisedButton?我已经设置
elevation: 0为非常RaisedButton但点击它时仍然出现阴影。
Nit*_*esh 26
由于凸起按钮已被弃用。
ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 0.0,
shadowColor: Colors.transparent,
),),
Run Code Online (Sandbox Code Playgroud)
这应该是解决方案。它将删除高程和阴影。
RaisedButton有四个不同的elevation参数。只需将它们全部设置为 0。
elevation: 0,
hoverElevation: 0,
focusElevation: 0,
highlightElevation: 0,
Run Code Online (Sandbox Code Playgroud)
由于 RaisingButton 已被弃用,应使用 ElevatedButton,因此该问题的解决方案也很简单。
elevation: MaterialStateProperty.all<double>(0)
Run Code Online (Sandbox Code Playgroud)
小智 5
您可以在这里找到答案: https ://api.flutter.dev/flutter/material/ButtonStyle-class.html
你必须使用:
.copyWith(elevation:ButtonStyleButton.allOrNull(0.0))
//Example
ElevatedButton(
child: Text("Your Text"),
onPressed: onPressed,
style: ElevatedButton.styleFrom(
backgroundColor: Color.fromRGBO(255, 255, 255, 1),
foregroundColor: Colors.black54,
shadowColor: Colors.transparent,
elevation: 0.0,
).copyWith(elevation:ButtonStyleButton.allOrNull(0.0))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3263 次 |
| 最近记录: |