Skip to content

Instantly share code, notes, and snippets.

@alvinthen
Created May 8, 2020 05:07
Show Gist options
  • Save alvinthen/7c160aa0b8c749db903a020dddb99237 to your computer and use it in GitHub Desktop.
Save alvinthen/7c160aa0b8c749db903a020dddb99237 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyWidget(),
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
Expanded(child: Container()),
Expanded(
child: ClipPath(
clipper: MyCustomClipper(),
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.bottomRight,
end: Alignment.topLeft,
colors: [
const Color(0xFFFA709A),
const Color(0xFFFEC140),
],
),
),
),
),
),
],
),
);
}
}
class MyCustomClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
Path path = Path()
..moveTo(size.width, 0)
..lineTo(size.width, size.height)
..lineTo(0, size.height)
..lineTo(0, 60)
..arcToPoint(
Offset(30, 30),
radius: Radius.circular(30),
)
..lineTo(size.width - 30, 30)
..arcToPoint(Offset(size.width, 0),
radius: Radius.circular(30), clockwise: false);
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment