mirrored_repositories/flutter-animation-1/lib
import 'package:flutter/material.dart';

class AnimatedOpacityPage extends StatefulWidget {
  const AnimatedOpacityPage({Key? key}) : super(key: key);

  @override
  State<AnimatedOpacityPage> createState() => _AnimatedOpacityPageState();
}

class _AnimatedOpacityPageState extends State<AnimatedOpacityPage> {

  double _opacity = 1.0;

  void _toggleOpacity() {
    setState(() => _opacity = _opacity == 0 ? 1.0 : 0);
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("AnimatedOpacity"),
        centerTitle: true,
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            AnimatedOpacity(
              opacity: _opacity,
              duration: Duration(seconds: 1),
              curve: Curves.fastOutSlowIn,
              child: FlutterLogo(
                size: 150,
              ),
            ),
            ElevatedButton(
              onPressed: _toggleOpacity,
              child: const Text("Fade Logo"),
            ),
          ],
        ),
      ),
    );
  }
}
