title: How do I make a button with an Image in flutter that highlights while someone is pressing it?
body: <p>I have a button that has an image as  as a child. I want it so that while the button is being pressed, the image changes to a different one, and when the user stops pressing the button, it goes back to its original image. </p>
  
  <p>Basically I want it to act like a raised button but with custom images for the raised and pressed states. </p>
  
  <p>Here's the relevant code:</p>
  
  <pre><code>class LoginButton extends StatefulWidget {
    @override
    _LoginButtonState createState() =&gt; new _LoginButtonState();
  }
  
  class _LoginButtonState extends State&lt;LoginButton&gt; {
    void _onClicked() {
      setState(() {
        //I don't know what I should put here to cause the image to redraw 
        //only on button press
  
      });
    }
  
    @override
    Widget build(BuildContext context) {
      var assetImage = new AssetImage("assets/loginscreen/btn.png");
      var image = new Image(image: assetImage, height: 50.0, width: 330.0);
      return new Container(
        height: image.height,
        width: image.width,
        child: new FlatButton(
          onPressed: _onClicked,
          child: new ConstrainedBox(
            constraints: new BoxConstraints.expand(),
            child: image,
          ),
        ),
      );
    }
  }
  </code></pre>