Created
August 24, 2020 10:23
-
-
Save gaetschwartz/670671cc336b1d8a28460b909906c260 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( | |
home: MyHomePage(), | |
); | |
} | |
} | |
class MyHomePage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Stack( | |
children: [ | |
Positioned.fill( | |
child: Center( | |
child: Text("Test"), | |
)), | |
Positioned.fill( | |
child: CustomPaint( | |
painter: Painter(), | |
)) | |
], | |
), | |
); | |
} | |
} | |
class Painter extends CustomPainter { | |
@override | |
void paint(Canvas canvas, Size size) { | |
Rect r = Rect.fromCenter(center: Offset(100, 100), height: 50, width: 50); | |
final leftCorner = Path.combine( | |
PathOperation.difference, | |
Path()..addRect(r), | |
Path() | |
..addRRect( | |
RRect.fromRectAndCorners( | |
r, | |
topRight: Radius.circular(50), | |
), | |
), | |
); | |
canvas.drawPath( | |
leftCorner, | |
Paint() | |
..style = PaintingStyle.fill | |
..color = Colors.blue); | |
} | |
@override | |
bool shouldRepaint(CustomPainter oldDelegate) => true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment