热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何更改ElevatedButton颜色或阴影Flutter

我一直在使用RaisedButton直到Flutter弃用它,我们不能再使用它了。有一个建议说“ElevatedButton改用”。

我一直在使用RaisedButton直到 Flutter 弃用它,我们不能再使用它了。有一个建议说“ElevatedButton改用”。所以,我想使用它,但我不能看到这样的属性colorelevationfocusColor等。

那么我怎样才能个性化一个ElevatedButton

回答


要更改ElevatedButton您的属性,您应该style:像这样使用该属性:

ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.blue, //button's fill color
onPrimary: Colors.red, //specify the color of the button's text and icons as well as the overlay colors used to indicate the hover, focus, and pressed states
onSurface: Colors.orange, //specify the button's disabled text, icon, and fill color
shadowColor: Colors.black, //specify the button's elevation color
elevation: 4.0, //buttons Material shadow
textStyle: TextStyle(fontFamily: 'roboto'), //specify the button's text TextStyle
padding: const EdgeInsets.only(top: 4.0, bottom: 4.0, right: 8.0, left: 8.0), //specify the button's Padding
minimumSize: Size(20, 40), //specify the button's first: width and second: height
side: BorderSide(color: Colors.yellow, width: 2.0, style: BorderStyle.solid), //set border for the button
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(35.0)), // set the buttons shape. Make its birders rounded etc
enabledMouseCursor: MouseCursor.defer, //used to construct ButtonStyle.mouseCursor
disabledMouseCursor: MouseCursor.uncontrolled, //used to construct ButtonStyle.mouseCursor
visualDensity: VisualDensity(horizontal: 0.0, vertical: 0.0), //set the button's visual density
tapTargetSize: MaterialTapTargetSize.padded, // set the MaterialTapTarget size. can set to: values, padded and shrinkWrap properties
animationDuration: Duration(milliseconds: 100), //the buttons animations duration
enableFeedback: true, //to set the feedback to true or false
alignment: Alignment.bottomCenter, //set the button's child Alignment
),
onPressed: () => {} , //set both onPressed and onLongPressed to null to see the disabled properties
onLongPress: () => {}, //set both onPressed and onLongPressed to null to see the disabled properties
child: Text('ElevatedButton')
),






推荐阅读
author-avatar
Nedo_zou
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有