Created
June 27, 2023 23:27
-
-
Save dirisujesse/15c303ba961994bd4fa7b98f6140e196 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
const Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
theme: ThemeData.dark().copyWith( | |
scaffoldBackgroundColor: darkBlue, | |
), | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Center( | |
child: MyWidget(), | |
), | |
), | |
); | |
} | |
} | |
class MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return const Scaffold( | |
backgroundColor: Colors.black, | |
body: Center( | |
child: Ticket() | |
) | |
); | |
} | |
} | |
class Ticket extends StatelessWidget { | |
const Ticket({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
double radius = 20; | |
return ClipPath( | |
clipper: const SemiCircleClipper(), | |
child: Container( | |
decoration: BoxDecoration( | |
color: Colors.white, | |
borderRadius: BorderRadius.circular(radius), | |
), | |
constraints: const BoxConstraints.tightFor( | |
width: 150, | |
height: 150, | |
), | |
child: const Center( | |
child: Text( | |
"%", | |
style: TextStyle( | |
fontSize: 80, | |
fontWeight: FontWeight.bold, | |
color: Colors.black, | |
), | |
), | |
), | |
), | |
); | |
} | |
} | |
class SemiCircleClipper extends CustomClipper<Path> { | |
const SemiCircleClipper(); | |
@override | |
Path getClip(Size size) { | |
Path path = Path(); | |
path.lineTo(0, size.height * 0.4); | |
path.quadraticBezierTo( | |
size.width * 0.15, | |
size.height * .5, | |
0, | |
size.height * 0.6, | |
); | |
path.lineTo(0, size.height); | |
path.lineTo(size.width, size.height); | |
path.lineTo(size.width, size.height * 0.6); | |
path.quadraticBezierTo( | |
size.width * 0.85, | |
size.height * .5, | |
size.width, | |
size.height * .4, | |
); | |
path.lineTo(size.width, 0); | |
path.close(); | |
return path; | |
} | |
@override | |
bool shouldReclip(covariant SemiCircleClipper oldClipper) => false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment