Created
July 9, 2018 19:47
-
-
Save rahichesoft/a049f0611f366024d4c39b5a68d561c0 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(new MaterialApp(home: new app())); | |
class app extends StatefulWidget { | |
@override | |
_appState createState() => new _appState(); | |
} | |
class _appState extends State<app> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Container( | |
child: Stack( | |
children: <Widget>[ | |
ClipPath( | |
clipper: CustomClip(), | |
child: Image.network( | |
"http://www.delonghi.com/Global/recipes/multifry/pizza_fresca.jpg", | |
width: double.infinity, | |
height: 400.0, | |
fit: BoxFit.cover, | |
)), | |
CustomPaint( | |
painter: BorderPainter(), | |
child: Container( | |
height: 400.0, | |
), | |
), | |
], | |
), | |
), | |
); | |
} | |
} | |
class BorderPainter extends CustomPainter { | |
@override | |
void paint(Canvas canvas, Size size) { | |
Paint paint = Paint() | |
..style = PaintingStyle.stroke | |
..strokeWidth = 10.0 | |
..color = Colors.red; | |
Path path = Path(); | |
// uncomment this and will get the border for all lines | |
path.lineTo(0.0, 0.0); | |
path.lineTo(size.width, 0.0); | |
path.lineTo(size.width, size.height * 0.8); | |
path.lineTo(0.0, size.height); | |
path.close(); | |
canvas.drawPath(path, paint); | |
} | |
@override | |
bool shouldRepaint(CustomPainter oldDelegate) => true; | |
} | |
class CustomClip extends CustomClipper<Path> { | |
@override | |
Path getClip(Size size) { | |
Path path = Path(); | |
path.lineTo(0.0, 0.0); | |
path.lineTo(size.width, 0.0); | |
path.lineTo(size.width, size.height * 0.8); | |
path.lineTo(0.0, size.height); | |
path.close(); | |
return path; | |
} | |
@override | |
bool shouldReclip(CustomClipper<Path> oldClipper) => true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can I add a shadow - blur - to the border color?