ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all<Color>(Colors.blue), // 设置背景颜色为蓝色 ), onPressed: () { // 按钮点击事件处理 }, child: Text('按钮'), ) 在上面的示例中,我们将backgroundColor属性设置为MaterialStateProperty.all<Color>(Colors.blue),这将使...
在Flutter中,ElevatedButton 是一个常用的按钮组件,用于显示带有阴影和填充颜色的按钮。要设置 ElevatedButton 的背景色,你可以使用 style 属性中的 backgroundColor 参数。以下是如何在Flutter中设置 ElevatedButton 背景色的详细解答: 1. 使用 style 属性设置背景色 在ElevatedButton 的构造函数中,你可以通过 style 属...
backgroundColor: 按钮的背景颜色,这里设置为透明。 splashColor: 按钮按下时的水波纹颜色。 Container: 用于包裹按钮的文本,并设置渐变背景。 应用场景 这种渐变背景的ElevatedButton可以用于需要视觉吸引力的按钮,例如在应用的主页、设置页面或任何需要突出显示的按钮上。
( child: ElevatedButton( style: ButtonStyle( backgroundColor: WidgetStateProperty.all(Colors.blue),// 按扭背景颜色foregroundColor: WidgetStateProperty.all(Colors.white),// 按钮文本颜色shape: WidgetStateProperty.all(RoundedRectangleBorder(borderRadius: BorderRadius.circular(10))),// 圆角), child:...
1.ElevatedButton 设置样式需要通过buttonStyle设置 buttonStyle可以设置的属性有: const ButtonStyle({ this.textStyle, //字体 this.backgroundColor, //背景色 this.foregroundColor, //前景色 this.overlayColor, // 高亮色,按钮处于focused, hovered, or pressed时的颜色 this.shadowColor, // 阴影颜色 this....
ElevatedButton按钮组件中是没法设置宽度高度的,我们要改变ElevatedButton按钮的宽度高度,可以在ElevatedButton按钮外部包裹一个Container去控制 SizedBox(height:80,width:200,child:ElevatedButton(style:ButtonStyle(backgroundColor:MaterialStateProperty.all(Colors.red),foregroundColor:MaterialStateProperty.all(Colors.black...
child: ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(constColor.fromARGB(255, 86, 244, 54)),//按扭背景颜色foregroundColor: MaterialStateProperty.all(Colors.black)),//字体颜色onPressed: () {}, child: Text("宽度高度"), ...
下面带大家一起看看Flutter如何实现圆角按钮和圆形按钮 圆角按钮 ElevatedButton(style:ButtonStyle(backgroundColor:MaterialStateProperty.all(Colors.blue),foregroundColor:MaterialStateProperty.all(Colors.white),elevation:MaterialStateProperty.all(20),shape:MaterialStateProperty.all(RoundedRectangleBorder(borderRadius:...
style:ButtonStyle(// backgroundColor: MaterialStateProperty.all(Color(0xffEDFCF5)),//背景颜色// foregroundColor: MaterialStateProperty.all(Color(0xff31C27C)), //字体颜色overlayColor:MaterialStateProperty.all(Color(0xff31C27C)),// 高亮色shadowColor:MaterialStateProperty.all(Colors.red),// 阴...
(//通过container 控制按钮大小height:60,width:200,child:ElevatedButton.icon(style:ButtonStyle(backgroundColor:MaterialStateProperty.all(Colors.red),//背景颜色foregroundColor:MaterialStateProperty.all(Colors.white),//文本颜色),onPressed:(){print("ElevatedButton.icon");},icon:constIcon(Icons.thumb_up,...