Created
July 9, 2018 19:23
-
-
Save rahichesoft/ae0b97534f92ac9fc67d9ed9f247f26c 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: CustomPaint( | |
painter: BorderPainter(), | |
child: ClipPath( | |
clipper: CustomClip(), | |
child: Container(child: Image.network( | |
"https://cdn.websites.hibu.com/c0c36335f54c47d89c0df32c0b7171e0/dms3rep/multi/mobile/Pizza%202_pGykYRpdQ1iN9d6Ohsnn-306x229.jpg", | |
width: double.infinity,fit: BoxFit.fitWidth,),), | |
), | |
), | |
), | |
); | |
} | |
} | |
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(); | |
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