Created
March 21, 2022 13:54
-
-
Save CoderNamedHendrick/c94d22667aac47dc6c2de6cefedc5e3d to your computer and use it in GitHub Desktop.
Custom clipping stuff
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: ClipPath( | |
clipper: ShapeClipper(), | |
child: Container( | |
height: 450, | |
width: 400, | |
color: Colors.blueAccent, | |
), | |
), | |
), | |
), | |
); | |
} | |
} | |
class ShapeClipper extends CustomClipper<Path> { | |
@override | |
Path getClip(Size size) { | |
Path path = Path() | |
..moveTo(0,0) | |
..lineTo(0, size.height) | |
..lineTo((size.width / 4) * 1, size.height - 50) | |
..lineTo((size.width / 4) * 2, size.height) | |
..lineTo((size.width / 4) * 3, size.height - 50) | |
..lineTo(size.width, size.height) | |
..lineTo(size.width, 0) | |
..close(); | |
return path; | |
} | |
@override | |
bool shouldReclip(covariant CustomClipper<Path> oldClipper) { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment