我应该将材质放置为原材料按钮的父级,以便它可以响应点击并显示初始颜色。 小部件树如下所示。
Widget build(BuildContext context) {
return new Container(
child: new Center(
child: new Stack(
alignment: Alignment.center,
children: <Widget>[
new Container(
child: new Padding(
padding: const EdgeInsets.all(5.0),
child: new Container(
child: new AudioComponent(
updateMe: [WatchableAudioProperties.audioPlayerState],
playerBuilder: (BuildContext context, AudioPlayer
player,
Widget child) {
IconData icon = Icons.play_arrow;
return new RawMaterialButton(
shape: new CircleBorder(),
fillColor: Colors.white,
splashColor: lightAccentColor,
highlightColor: lightAccentColor.withOpacity(0.5),
elevation: 10.0,
highlightElevation: 5.0,
onPressed: (){},
child: new Padding(
padding: const EdgeInsets.all(8.0),
child: new Icon(
icon,
color: accentColor,
size: 50.0,
),
),
);
},
),
),
),
),
new Container(
height: 151.0,
width: 151.0,
child: waves,
),
],
),
),
);
}
如果我将另一个容器添加到堆栈并放置一个类似的RawMaterial按钮,它会根据需要响应,即使不在任何地方添加材料小部件。我不明白为什么堆栈中第一个容器中的RawButton无法正常工作
答案 0 :(得分:0)
如果您对RawMaterialButton
的定义中包含以下代码,您希望如何做出反应?
onPressed: (){},