Skip to content

Instantly share code, notes, and snippets.

@hectorAguero
Created November 21, 2024 15:14
Show Gist options
  • Save hectorAguero/de14ed0a0cec3ae2bd76c1a42dcc1eba to your computer and use it in GitHub Desktop.
Save hectorAguero/de14ed0a0cec3ae2bd76c1a42dcc1eba 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(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: CustomPaint(
painter: MyPainter(),
child: Container(
height: 500,
width: 500,
),
),
),
),
);
}
}
class MyPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
Paint paint = Paint();
Path path = Path();
final double width = size.width;
final double height = size.height;
final double halfSize = size.width / 2;
final double radius = size.width * 0.04;
final double halfRadius = size.width * 0.02;
final double startHeight = height * 0.01;
final double oneFifthSize = size.width / 5;
// Path number 1
paint.color = Color(0xff00AEC7);
path = Path();
path.lineTo(halfSize - radius, startHeight);
path.cubicTo(halfSize - halfRadius, 0, halfSize + halfRadius, 0,
halfSize + radius, startHeight);
path.cubicTo(halfSize + radius, startHeight, width - radius,
oneFifthSize + halfRadius, width - radius, oneFifthSize + halfRadius);
path.cubicTo(width - halfRadius, height * 0.24, width, height * 0.26, width,
height * 0.29);
path.cubicTo(
width, height * 0.29, width, height * 0.71, width, height * 0.71);
path.cubicTo(width, height * 0.74, width * 0.98, height * 0.77,
width * 0.96, height * 0.78);
path.cubicTo(width * 0.96, height * 0.78, width * 0.54, height,
width * 0.54, height * 0.99);
path.cubicTo(width * 0.52, height, width * 0.48, height, width * 0.46,
height * 0.99);
path.cubicTo(width * 0.46, height, width * 0.04, height * 0.78,
width * 0.04, height * 0.78);
path.cubicTo(
width * 0.02, height * 0.77, 0, height * 0.74, 0, height * 0.71);
path.cubicTo(0, height * 0.71, 0, height * 0.29, 0, height * 0.29);
path.cubicTo(0, height * 0.26, width * 0.02, height * 0.24, width * 0.04,
height * 0.22);
path.cubicTo(width * 0.04, height * 0.22, width * 0.46, height * 0.01,
width * 0.46, height * 0.01);
path.cubicTo(width * 0.46, height * 0.01, width * 0.46, height * 0.01,
width * 0.46, height * 0.01);
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment