-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.dart
More file actions
124 lines (115 loc) · 3.58 KB
/
Copy pathmain.dart
File metadata and controls
124 lines (115 loc) · 3.58 KB
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
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Custom Card Design',
theme: ThemeData(
primarySwatch: Colors.amber,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.amber,
child: Center(
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50.0)),
elevation: 10.0,
child: Container(
width: 300.0,
height: 400.0,
child: Stack(
alignment: Alignment.bottomCenter,
children: [
// This will hold the Image in the back ground:
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50.0),
color: Colors.pink[100]),
),
// This is the Custom Shape Container
Positioned(
bottom: 0.0,
left: 0.0,
child: Container(
color: Colors.red,
child: CustomPaint(
painter: CustomContainerShapeBorder(
height: 100.0,
width: 300.0,
radius: 50.0,
),
),
),
),
// This Holds the Widgets Inside the the custom Container;
Positioned(
bottom: 10.0,
child: Container(
height: 80.0,
width: 260.0,
color: Colors.grey.withOpacity(0.6),
child: Center(
child: FlatButton(
onPressed: () {
print('Button Pressed');
},
),
),
),
),
],
),
),
),
));
}
}
/// The {CustomContainerShapeBorder} should be reactibe with different sizes,
/// If it isn't then chamge the offset values.
class CustomContainerShapeBorder extends CustomPainter {
final double height;
final double width;
final Color fillColor;
final double radius;
CustomContainerShapeBorder({
this.height: 400.0,
this.width: 300.0,
this.fillColor: Colors.white,
this.radius: 50.0,
});
@override
void paint(Canvas canvas, Size size) {
Path path = new Path();
path.moveTo(0.0, -radius);
path.lineTo(0.0, -(height - radius));
path.conicTo(0.0, -height, radius, -height, 1);
path.lineTo(width - radius, -height);
path.conicTo(width, -height, width, -(height + radius), 1);
path.lineTo(width, -(height - radius));
path.lineTo(width, -radius);
path.conicTo(width, 0.0, width - radius, 0.0, 1);
path.lineTo(radius, 0.0);
path.conicTo(0.0, 0.0, 0.0, -radius, 1);
path.close();
canvas.drawPath(path, Paint()..color = fillColor);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}