/
main.dart
52 lines (45 loc) · 1.33 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
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
// Outer white container with padding
body: Container(
color: Colors.white,
padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 80),
// Inner yellow container
child: Container(
// pass double.infinity to prevent shrinking of the painter area to 0.
width: double.infinity,
height: double.infinity,
color: Colors.black,
child: CustomPaint(painter: RectanglePainter()),
),
),
),
);
}
}
class RectanglePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..style = PaintingStyle.stroke
..strokeWidth = 4.0
..color = Colors.indigo;
canvas.drawRect(
const Rect.fromLTWH(100, 100, 100, 100),
paint,
);
}
@override
bool shouldRepaint(RectanglePainter oldDelegate) => false;
}