Skip to content

Instantly share code, notes, and snippets.

@Chinmay-KB
Last active February 20, 2025 08:05
Show Gist options
  • Select an option

  • Save Chinmay-KB/d714f4f4d36c1cb93b82d06375023bdd to your computer and use it in GitHub Desktop.

Select an option

Save Chinmay-KB/d714f4f4d36c1cb93b82d06375023bdd to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.black,
body: Center(
child: ClipPath(
clipper: RoundyClipper(),
child: Container(
width: 250,
height: 200,
color: Colors.white,
child: FlutterLogo(),
),
),
),
),
);
}
}
class RoundyClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = Path();
double borderRadius = 20.0;
double tabWidth = size.width * 0.4;
double tabHeight = size.height * 0.18;
path.moveTo(borderRadius, 0);
path.lineTo(tabWidth - borderRadius, 0);
path.quadraticBezierTo(tabWidth, 0, tabWidth, borderRadius);
path.lineTo(tabWidth, tabHeight - borderRadius);
path.quadraticBezierTo(tabWidth, tabHeight, tabWidth + borderRadius, tabHeight);
path.lineTo(size.width - borderRadius, tabHeight);
path.quadraticBezierTo(size.width, tabHeight, size.width, tabHeight + borderRadius);
path.lineTo(size.width, size.height - borderRadius);
path.quadraticBezierTo(size.width, size.height, size.width - borderRadius, size.height);
path.lineTo(borderRadius, size.height);
path.quadraticBezierTo(0, size.height, 0, size.height - borderRadius);
path.lineTo(0, borderRadius);
path.quadraticBezierTo(0, 0, borderRadius, 0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment