简体   繁体   中英

Remove the drop shadow from a RaisedButton in Flutter

Is there a way to completely remove the drop shadow under the RaisedButton ? I've set elevation: 0 to that very RaisedButton but the drop shadow still appears when tapping it.

Is there a way to completely remove the drop shadow under the RaisedButton ? I've set elevation: 0 to that very RaisedButton but the drop shadow still appears when tapping it.

Since raised button is deprecated.

ElevatedButton(
                style: ElevatedButton.styleFrom(
                  elevation: 0.0,
                  shadowColor: Colors.transparent,
               
                ),),

This should be the solution. It will remove the elevation and the shadows.

由于 RaisedButton 已被弃用而应使用 ElevatedButton,因此解决此问题的方法也很简单。

elevation: MaterialStateProperty.all<double>(0)

You can find the answer here:https://api.flutter.dev/flutter/material/ButtonStyle-class.html

You have to use:

.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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM