-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.dart
178 lines (165 loc) · 5.53 KB
/
main.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
//var size = MediaQuery.of(context).size;
return const MaterialApp(
title: 'A Custom Home Page',
home: DashBoard(
// size: size,
),
);
}
}
class DashBoard extends StatelessWidget {
//final Size size;
const DashBoard({
Key? key,
//required this.size,
}) : super(key: key);
@override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
return MaterialApp(
title: 'A Custom Home Page',
/// ignore: todo
///TODO: we'll make a custom global theme later
///
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.black12,
leading: const Icon(Icons.menu),
title: const Text(
"A Custom Home Page",
textAlign: TextAlign.center,
),
),
body: Stack(
children: <Widget>[
Container(
padding: const EdgeInsets.all(5),
child: CustomPaint(
painter: ShapingPainter(),
child: Container(
height: size.height / 1,
),
),
),
Container(
margin: const EdgeInsets.all(10),
child: Padding(
padding: const EdgeInsets.all(10),
child: Row(
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.network(
'https://cdn.pixabay.com/photo/2021/12/05/10/28/nature-6847175_960_720.jpg',
width: 150,
height: 100,
),
Container(
padding: const EdgeInsets.all(7),
child: const Text(
'Let\'s go',
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.network(
'https://cdn.pixabay.com/photo/2021/11/13/23/06/tree-6792528_960_720.jpg',
width: 150,
height: 100,
),
Container(
padding: const EdgeInsets.all(7),
child: const Text(
'Let\'s go',
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
),
),
),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.network(
'https://cdn.pixabay.com/photo/2021/12/12/20/26/flow-6866055_960_720.jpg',
width: 150,
height: 100,
),
Container(
padding: const EdgeInsets.all(7),
child: const Text(
'Let\'s go',
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
color: Colors.blue,
),
),
),
],
),
],
),
),
)
],
),
),
);
}
}
class ShapingPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint();
/// setting the paint color greyish
/// so it could cover the lower half of the screen
///
paint.color = Colors.black12;
/// Creating a rectangle with size and width same as the canvas
/// It'll be going to cover the whole screen
///
var rect = Rect.fromLTWH(0, 0, size.width, size.height);
/// Drawing the rectangle using the paint
///
canvas.drawRect(rect, paint);
/// Covering the upper half of the rectangle
///
paint.color = Colors.purpleAccent;
// Firstly, creating a path to form the shape
var path = Path();
path.lineTo(0, size.height);
path.lineTo(size.width, 0);
// Secondly, closing the path to form a bounded shape
path.close();
canvas.drawPath(path, paint);
// Setting the color property of the paint
paint.color = Colors.white;
// Center of the canvas is (x,y) => (width/2, height/2)
var center = Offset(size.width / 2, size.height / 2);
// Finally, drawing the circle with center having radius 95.0
canvas.drawCircle(center, 95.0, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) => false;
}