content: import 'package:flutter/material.dart';
  
  import '../../types/animate_do_mixins.dart';
  import '../../types/animate_do_types.dart';
  
  /// [key]: optional widget key reference
  /// [child]: mandatory, widget to animate
  /// [duration]: how much time the animation should take
  /// [delay]: delay before the animation starts
  /// [controller]: optional/mandatory, exposes the animation controller created by Animate_do
  /// [manualTrigger]: boolean that indicates if you want to trigger the animation manually with the controller
  /// [animate]: For a State controller property, if you re-render changing it from false to true, the animation will be fired immediately
  /// [onFinish]: callback that returns the direction of the animation, [AnimateDoDirection.forward] or [AnimateDoDirection.backward]
  /// [curve]: curve for the animation
  class FadeOut extends StatefulWidget {
    final Widget child;
    final Duration duration;
    final Duration delay;
    final Function(AnimationController)? controller;
    final bool manualTrigger;
    final bool animate;
    final Function(AnimateDoDirection direction)? onFinish;
    final Curve curve;
  
    FadeOut({
      key,
      required this.child,
      this.duration = const Duration(milliseconds: 300),
      this.delay = const Duration(milliseconds: 0),
      this.controller,
      this.manualTrigger = false,
      this.animate = true,
      this.onFinish,
      this.curve = Curves.easeOut,
    }) : super(key: key) {
      if (manualTrigger == true && controller == null) {
        throw FlutterError('If you want to use manualTrigger:true, \n\n'
            'Then you must provide the controller property, that is a callback like:\n\n'
            ' ( controller: AnimationController) => yourController = controller \n\n');
      }
    }
  
    @override
    FadeOutState createState() => FadeOutState();
  }
  
  class FadeOutState extends State<FadeOut>
      with SingleTickerProviderStateMixin, AnimateDoState {
    late Animation<double> animation;
  
    @override
    void dispose() {
      disposed = true;
      controller.dispose();
      super.dispose();
    }
  
    @override
    void initState() {
      super.initState();
  
      controller = AnimationController(duration: widget.duration, vsync: this);
      animation = Tween(begin: 1.0, end: 0.0)
          .animate(CurvedAnimation(curve: widget.curve, parent: controller));
  
      configAnimation(
        delay: widget.delay,
        animate: widget.animate,
        manualTrigger: widget.manualTrigger,
        infinite: false,
        onFinish: widget.onFinish,
        controllerCallback: widget.controller,
      );
    }
  
    @override
    Widget build(BuildContext context) {
      buildAnimation(
        delay: widget.delay,
        animate: widget.animate,
        manualTrigger: widget.manualTrigger,
        infinite: false,
        onFinish: widget.onFinish,
        controllerCallback: widget.controller,
      );
  
      return FadeTransition(
        opacity: animation,
        child: widget.child,
      );
    }
  }
  
  extension FadeOutExtension on Widget {
    Widget fadeOut({
      Key? key,
      Duration duration = const Duration(milliseconds: 800),
      Duration delay = const Duration(milliseconds: 0),
      Function(AnimationController)? controller,
      bool manualTrigger = false,
      bool animate = true, // Cambiado a true por defecto
      Function(AnimateDoDirection direction)? onFinish,
      Curve curve = Curves.easeOut,
    }) {
      return FadeOut(
        key: key,
        duration: duration,
        delay: delay,
        controller: controller,
        manualTrigger: manualTrigger,
        animate: animate,
        onFinish: onFinish,
        curve: curve,
        child: this,
      );
    }
  }
  