import 'package:flutter/material.dart';

class InwardCurvedContainer extends StatelessWidget {
  final Widget child;
  const InwardCurvedContainer({super.key, required this.child});

  @override
  Widget build(BuildContext context) {
    return ClipPath(
      clipper: InwardAndBottomConvexClipper(),
      child: Container(
        width: double.infinity,
        height: 700,
        decoration: const BoxDecoration(
          gradient: LinearGradient(
            begin: Alignment.topLeft,
            end: Alignment.bottomRight,
            colors: [
              Color(0xFFFFF5F5),
              Color(0xFFFDCDCE),
              Color(0xFFFFF5F5),
            ],
          ),
        ),
        child: child,
      ),
    );
  }
}

class InwardAndBottomConvexClipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    Path path = Path();

    // 👇 Start at top-left corner
    path.moveTo(0, 0);

    // ===== Top inward (concave) curve =====
    path.quadraticBezierTo(
      size.width / 2, 60, // Control point (lower Y = deeper dip)
      size.width, 0,      // End of top curve
    );

    // Right edge down
    path.lineTo(size.width, size.height - 80);

    // ===== Bottom outward (convex) curve =====
    path.quadraticBezierTo(
      size.width / 2, size.height + 20, // Control point (higher Y = bulge outward)
      0, size.height - 80,              // End of bottom curve
    );

    // Close back to start
    path.close();

    return path;
  }

  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
