import 'package:flutter/material.dart';

mixin SizeTransitionMixin {
  Widget handleSizeTransition(Widget child, Animation<double> animation) {
    return SizeTransition(
      sizeFactor: Tween<double>(begin: 0, end: 1).animate(
        CurvedAnimation(parent: animation, curve: const Interval(0, 0.3)),
      ),
      axisAlignment: 1,
      child: DualTransitionBuilder(
        animation: animation,
        forwardBuilder: (context, animation, child) {
          return FadeTransition(
            opacity: Tween<double>(begin: 0, end: 1).animate(
              CurvedAnimation(parent: animation, curve: const Interval(0.7, 1)),
            ),
            child: child,
          );
        },
        reverseBuilder: (context, animation, child) {
          return FadeTransition(
            opacity: Tween<double>(begin: 1, end: 0).animate(
              CurvedAnimation(parent: animation, curve: const Interval(0, 0.3)),
            ),
            child: child,
          );
        },
        child: child,
      ),
    );
  }
}
