How to access the Widget from within its own callback (onPressed) in Dart/Flutter

Viewed 3426

I have the following code:

  @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(), I want to change the Buttons style - to represent sprinkler activity.

Therefore, I would need to acces the MaterialButton Widget itself.

But how to I access it from within the callback?

Thanks a lot in advance, and sorry for the n00b question, I am new to Dart and Flutter ;)

3 Answers
Related