【发布时间】:2017-08-02 20:53:15
【问题描述】:
我有以下代码:
@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(),我想改变 Buttons 样式 - 代表喷水器活动。
因此,我需要访问 MaterialButton 小部件本身。
但是如何从回调中访问它?
提前非常感谢,对于 n00b 问题,我很抱歉,我是 Dart 和 Flutter 的新手 ;)
【问题讨论】: