content: import 'package:flutter/material.dart';
  
  import '../../types/animate_do_mixins.dart';
  import '../../types/animate_do_types.dart';
  
  class BounceIn 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;
  
    BounceIn({
      Key? key,
      required this.child,
      this.duration = const Duration(milliseconds: 750),
      this.delay = const Duration(milliseconds: 0),
      this.controller,
      this.manualTrigger = false,
      this.animate = true,
      this.onFinish,
      this.curve = Curves.easeOutCubic,
    }) : 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
    _BounceInState createState() => _BounceInState();
  }
  
  class _BounceInState extends State<BounceIn>
      with SingleTickerProviderStateMixin, AnimateDoState {
    late AnimationController controller;
    late Animation<double> scale;
    late Animation<double> opacity;
    bool hasBeenInitialized = false;
  
    @override
    void initState() {
      super.initState();
      controller = AnimationController(duration: widget.duration, vsync: this);
  
      final CurvedAnimation curvedAnimation = CurvedAnimation(
        parent: controller,
        curve: widget.curve,
      );
  
      scale = TweenSequence<double>([
        TweenSequenceItem(
          tween: Tween(begin: 0.3, end: 1.1),
          weight: 20,
        ),
        TweenSequenceItem(
          tween: Tween(begin: 1.1, end: 0.9),
          weight: 20,
        ),
        TweenSequenceItem(
          tween: Tween(begin: 0.9, end: 1.03),
          weight: 20,
        ),
        TweenSequenceItem(
          tween: Tween(begin: 1.03, end: 0.97),
          weight: 20,
        ),
        TweenSequenceItem(
          tween: Tween(begin: 0.97, end: 1.0),
          weight: 20,
        ),
      ]).animate(curvedAnimation);
  
      opacity = TweenSequence<double>([
        TweenSequenceItem(
          tween: Tween(begin: 0.0, end: 1.0),
          weight: 60,
        ),
        TweenSequenceItem(
          tween: Tween(begin: 1.0, end: 1.0),
          weight: 40,
        ),
      ]).animate(curvedAnimation);
  
      /// Provided by the mixing [AnimateDoState] class
      configAnimation(
        delay: widget.delay,
        animate: widget.animate,
        manualTrigger: widget.manualTrigger,
        infinite: false,
        onFinish: widget.onFinish,
        controllerCallback: widget.controller,
      );
    }
  
    @override
    void dispose() {
      disposed = true;
      controller.dispose();
      super.dispose();
    }
  
    @override
    Widget build(BuildContext context) {
      /// Provided by the mixing [AnimateDoState] class
      buildAnimation(
        delay: widget.delay,
        animate: widget.animate,
        manualTrigger: widget.manualTrigger,
        infinite: false,
        onFinish: widget.onFinish,
        controllerCallback: widget.controller,
      );
  
      return AnimatedBuilder(
        animation: controller,
        builder: (BuildContext context, Widget? child) {
          return Transform.scale(
            scale: scale.value,
            alignment: Alignment.center,
            child: Opacity(
              opacity: opacity.value,
              child: widget.child,
            ),
          );
        },
      );
    }
  }
  
  extension BounceInExtension on Widget {
    /// Applies a bounce-in animation with customizable options
    Widget bounceIn({
      Duration duration = const Duration(milliseconds: 1000),
      Duration delay = const Duration(milliseconds: 0),
      Function(AnimationController)? controller,
      bool manualTrigger = false,
      bool animate = true,
      Function(AnimateDoDirection direction)? onFinish,
      Curve curve = Curves.bounceOut,
    }) {
      return BounceIn(
        duration: duration,
        delay: delay,
        controller: controller,
        manualTrigger: manualTrigger,
        animate: animate,
        onFinish: onFinish,
        curve: curve,
        child: this,
      );
    }
  }
  