-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustompaint.dart
50 lines (45 loc) · 1.23 KB
/
custompaint.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import 'package:flutter/material.dart';
class CustomPaintWidget extends StatelessWidget {
const CustomPaintWidget({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("CustomPaint"),
),
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Center(
child: CustomPaint(
painter: DemoPainter(),
child: const Text(
'This is Pac man',
style: TextStyle(
color: Colors.black,
backgroundColor: Colors.white,
fontSize: 30.0),
),
)),
));
}
}
class DemoPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
var center = size / 2;
var paint = Paint()..color = Colors.yellow;
canvas.drawArc(
Rect.fromCenter(
center: Offset(center.width, center.height),
width: 250,
height: 250),
0.4,
2 * 3.14 - 0.8,
true,
paint);
}
@override
bool shouldRepaint(DemoPainter oldDelegate) => false;
@override
bool shouldRebuildSemantics(DemoPainter oldDelegate) => false;
}