Set up a trigger for animation and choose an end value
Configure the animation to trigger when the user clicks Show details. To do this, change opacity state using the onPressed() handler for TextButton. To make the FadeInDemo widget become fully visible when the user clicks Show details, use the onPressed() handler to set opacity to 1:
TextButton(
child: const Text(
‘Show Details’,
style: TextStyle(color: Colors.blueAccent),
),
onPressed: () => {},
onPressed: () => setState(() {
opacity = 1;
}),
),