+
                    ),

29

+
                    onPressed: () => setState(() {

30

+
                      opacity = 1;

31

+
                    }),

32

+
                  ),

30
33

AnimatedOpacity(

31
34

duration: const Duration(seconds: 2),

32
35

opacity: opacity,

Notice that you only need to set the start and end values of opacity.
  The AnimatedOpacity widget manages everything in between.

Fade-in (complete)

Here’s the example with the completed changes you’ve made—run this
example and click the Show details button to trigger the animation.

Putting it all together