我是 Flutter 编程的新手,我想问一下是否可以将图像制作为按钮背景 flutter?这是我的图像 Assets :
final _backgroundButton = new AssetImage("assets/background_button.png");
这是我的按钮:
RaisedButton(
child: const Text('LANJUTKAN'),
color: Theme.of(context).accentColor,
elevation: 0.0,
splashColor: Colors.blueGrey,
onPressed: () {
// Perform some action
},
),
有人知道怎么做吗?只要我可以将图像设置为背景,我就可以将凸起按钮更改为扁平按钮或其他任何东西。谢谢!
最佳答案
“RaisedButton”是一个 Material 组件,它的形状取决于“ Material 设计”角色,您可以创建自己的自定义按钮小部件
GestureDetector(
child: Container(
width:120,
height: 40,
decoration: BoxDecoration(
color: Colors.black,
image: DecorationImage(
image:AssetImage("assets/background_button.png"),
fit:BoxFit.cover
),
child: Text("clickMe") // button text
)
),onTap:(){
print("you clicked me");
}
)
关于dart - 带有图像背景 flutter 的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55216108/