Created
June 5, 2020 13:30
-
-
Save vijayinyoutube/6bef66c0ed8a9c0385758148207617fb to your computer and use it in GitHub Desktop.
This file contains 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'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
title: 'Custom Clipper', | |
theme: ThemeData(), | |
home: MyHomePage(), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: ClipPath( | |
clipper: MyClipper(), | |
child: Container( | |
padding: EdgeInsets.symmetric(horizontal: 10), | |
height: MediaQuery.of(context).size.height / 2, | |
width: double.infinity, | |
decoration: BoxDecoration( | |
gradient: LinearGradient( | |
begin: Alignment.topRight, | |
end: Alignment.bottomLeft, | |
colors: [ | |
Color(0xFF3383CD), | |
Color(0xFF11249F), | |
], | |
), | |
), | |
), | |
), | |
); | |
} | |
} | |
class MyClipper extends CustomClipper<Path> { | |
@override | |
Path getClip(Size size) { | |
var path = Path(); | |
path.lineTo(0, size.height - 80); | |
path.quadraticBezierTo( | |
size.width / 2, size.height, size.width, size.height - 80); | |
path.lineTo(size.width, 0); | |
path.close(); | |
return path; | |
} | |
@override | |
bool shouldReclip(CustomClipper<Path> oldClipper) { | |
return false; | |
} | |
} |
Author
vijayinyoutube
commented
Jun 5, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment