forked from md-siam/widget_of_the_day
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_paint.dart
101 lines (95 loc) · 3.37 KB
/
custom_paint.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import 'package:flutter/material.dart';
class MyCustomPaint extends StatelessWidget {
const MyCustomPaint({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
return Scaffold(
backgroundColor: Colors.deepPurple[100],
appBar: AppBar(title: const Text('Custom Paint')),
body: Stack(
children: [
Positioned(
bottom: 0,
left: 0,
child: SizedBox(
width: size.width,
height: 80,
child: Stack(
children: [
CustomPaint(
size: Size(size.width, 80),
painter: BNBCustonPainter(),
),
Center(
heightFactor: 0.6,
child: FloatingActionButton(
onPressed: () {},
backgroundColor: Colors.purple,
elevation: 8.0,
child: const Icon(Icons.shopping_basket),
),
),
SizedBox(
width: size.width,
height: 80,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
IconButton(
icon: const Icon(Icons.home),
color: Colors.purple,
onPressed: () {},
),
IconButton(
icon: const Icon(Icons.restaurant_menu),
color: const Color(0xFFAEAEAE),
onPressed: () {},
),
SizedBox(width: size.width * 0.20),
IconButton(
icon: const Icon(Icons.bookmark),
color: const Color(0xFFAEAEAE),
onPressed: () {},
),
IconButton(
icon: const Icon(Icons.notifications),
color: const Color(0xFFAEAEAE),
onPressed: () {},
),
],
),
),
],
),
),
),
],
),
);
}
}
class BNBCustonPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
Paint paint = Paint()
..color = Colors.white
..style = PaintingStyle.fill;
Path path = Path()..moveTo(0, 20);
path.quadraticBezierTo(size.width * 0.20, 0, size.width * 0.35, 0);
path.quadraticBezierTo(size.width * 0.40, 0, size.width * 0.40, 20);
path.arcToPoint(Offset(size.width * 0.60, 20),
radius: const Radius.circular(10.0), clockwise: false);
path.quadraticBezierTo(size.width * 0.60, 0, size.width * 0.65, 0);
path.quadraticBezierTo(size.width * 0.80, 0, size.width, 20);
path.lineTo(size.width, size.height);
path.lineTo(0, size.height);
path.close();
canvas.drawShadow(path, Colors.black, 8, true);
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(BNBCustonPainter oldDelegate) => false;
@override
bool shouldRebuildSemantics(BNBCustonPainter oldDelegate) => false;
}