此按钮将需要在将要创建
build的
State的
StatefulWidget,国家必须有一个成员变量
bool pressAttention =false;。正如Edman建议的那样,您需要在
setState回调中进行状态更改以使Widget重绘。
new RaisedButton( child: new Text('Attention'), textColor: Colors.white, shape: new RoundedRectangleBorder( borderRadius: new BorderRadius.circular(30.0), ), color: pressAttention ? Colors.grey : Colors.blue, onPressed: () => setState(() => pressAttention = !pressAttention),);


