Skip to content

Instantly share code, notes, and snippets.

@gaetschwartz
Created August 24, 2020 10:23
Show Gist options
  • Save gaetschwartz/670671cc336b1d8a28460b909906c260 to your computer and use it in GitHub Desktop.
Save gaetschwartz/670671cc336b1d8a28460b909906c260 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: 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