Search code examples
fluttercontainers

How to create a custom container?


enter image description here
I'm looking for a solution for the opposite design: The right side shape in left side How to do ?

class CustomPath extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    final path = new Path();
    path.lineTo(size.width, 0);
    path.lineTo(size.width - 10, size.height / 2);
    path.lineTo(size.width, size.height);
    path.lineTo(0, size.height);
    path.close();
    return path;
  }

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

Solution

  • You can try this solution:

    class CustomPath extends CustomClipper<Path> {
      @override
      Path getClip(Size size) {
        final path = new Path();
        path.lineTo(10, size.height / 2);  
        path.lineTo(0, size.height);       
        path.lineTo(size.width, size.height);
        path.lineTo(size.width, 0);    
        path.close();
        return path;
      }
    
      @override
      bool shouldReclip(covariant CustomClipper<Path> oldClipper) {
        return true;
      }
    }