我有以下代码:
@override
Widget build(BuildContext context) {
return new Container(
height: 72.0, // in logical pixels
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
decoration: new BoxDecoration(color: Colors.white),
// Row is a horizontal, linear layout.
child: new MaterialButton(
child: new Text(
_sprinkler.name,
style: new TextStyle(color: Colors.white)
),
splashColor: Colors.blueAccent,
color: Colors.blue[800],
onPressed: () {
print("onTap(): tapped" + _sprinkler.name);
},
),
);
}
在 onPressed() 回调中,我想改变按钮的样式 - 以表示洒水器的活动。
因此,我需要访问 MaterialButton Widget 本身。
但是我该如何在回调中访问它呢?
非常感谢您的帮助,对于这个初学者的问题,我很抱歉,我刚接触 Dart 和 Flutter ;)
[dart] 类 '_SprinklerListItem' 中没有定义 'setState' 方法。
- wzr1337StatefulWidget
吗? - Bram Vanbilsen