Skip to content

Instantly share code, notes, and snippets.

@dhruvilp
Created October 15, 2020 03:29
Show Gist options
  • Select an option

  • Save dhruvilp/27e5f4b46a06086474af1bcfc5cf3f5a to your computer and use it in GitHub Desktop.

Select an option

Save dhruvilp/27e5f4b46a06086474af1bcfc5cf3f5a to your computer and use it in GitHub Desktop.
Custom Shape Generated Using "Fluttershapemaker"
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: InkWell(
onTap: (){},
child: CustomPaint(
size: Size(600,350),
painter: RPSCustomPainter(Colors.red),
),
),
);
}
}
// Generated using (https://fluttershapemaker.com/#/)
class RPSCustomPainter extends CustomPainter {
final Color kColor;
RPSCustomPainter(this.kColor);
@override
void paint(Canvas canvas, Size size) {
Paint paint = new Paint()
..color = kColor
..style = PaintingStyle.fill;
Path path = Path();
path.moveTo(size.width * 0.00, size.height * 0.43);
path.quadraticBezierTo(size.width * 0.21, size.height * 0.36,
size.width * 0.37, size.height * 0.43);
path.quadraticBezierTo(size.width * 0.37, size.height * 0.57,
size.width * 0.50, size.height * 0.57);
path.quadraticBezierTo(size.width * 0.62, size.height * 0.57,
size.width * 0.63, size.height * 0.43);
path.quadraticBezierTo(size.width * 0.79, size.height * 0.36,
size.width * 1.00, size.height * 0.43);
path.lineTo(size.width * 1.00, size.height * 0.71);
path.lineTo(size.width * 0.63, size.height * 0.71);
path.lineTo(size.width * 0.50, size.height * 0.71);
path.lineTo(size.width * 0.37, size.height * 0.71);
path.lineTo(size.width * 0.00, size.height * 0.71);
path.lineTo(size.width * 0.00, size.height * 0.43);
path.close();
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment