0

I tried the following code, What is the best way to do that curve. My code is separated into 2 parts: first the entire screen wrapped with stack second the function of CustomBigArcClipper

 return Scaffold(
      backgroundColor: Colors.blue,
      body: Stack(
        alignment: Alignment.center,
        children: [
          Positioned(
            top: 0,
            bottom: MediaQuery.of(context).size.height * 0.5,
            left: 0,
            right: 0,
            child: ClipPath(
              clipper: CustomBigArcClipper(),
              child: Container(
                height: 600,
                color: Colors.green,
              ),
            ),
          ),
        ],
      ),
    );



class CustomBigArcClipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    final path = Path();
    double w = size.width;
    double h = size.height;
    path.lineTo(0, h);
    path.quadraticBezierTo(w * 0.5, h - 100, w, h);
    path.lineTo(w, 0);
    path.close();
    return path;
  }

  @override
  bool shouldReclip(covariant CustomClipper<Path> oldClipper) {
    return true;
  }
}

enter image description here

Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56
Ayz
  • 181
  • 1
  • 9

1 Answers1

1

You can split the shape into two sections, top one is a rectangle, bottom is a half circle.

class CustomBigArcClipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    final path = Path();
    double w = size.width;
    double h = size.height;
    path.addRect(Rect.fromLTWH(0, 0, w, h * 0.5));
    path.addOval(Rect.fromCircle(
      center: Offset(w * 0.5, h * 0.5),
      radius: w / 2,
    ));
    return path;
  }

  @override
  bool shouldReclip(covariant CustomClipper<Path> oldClipper) {
    return true;
  }
}
Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56