title: Flutter - change text opacity on press
body: <p>Basically I want to change the opacity of the text when it is clicked. Like when it is pressed, its opacity becomes 0.4 and once it is released, its opacity becomes 1.0. Currently I'm trying to use <code>AnimatedOpacity</code> and I can only change the opacity on tap.</p>
  <pre class="lang-dart prettyprint-override"><code>double textOpacity = 1.0;
  //some widgets
   AnimatedOpacity(
     duration: const Duration(milliseconds: 100),
     opacity: textOpacity,
     child: GestureDetector(
       child: Text(
         'Tap',
         style: TextStyle(
            color: CupertinoColors.systemBlue,
         ),
       ),
       onTap: () {
         setState(() =&gt; textOpacity = 0.4);
       }
    ),
  ),
  </code></pre>
  <p>I also tried</p>
  <pre class="lang-dart prettyprint-override"><code>onForcePressStart: (details) =&gt;
      setState(() =&gt; textOpacity = 0.4),
  onForcePressEnd: (details) =&gt;
      setState(() =&gt; textOpacity = 1.0),
  </code></pre>
  <p>but it didn't work.</p>
  <p>Can any one help me with it? Thanks!</p>