|
@@ -0,0 +1,89 @@
|
|
1
|
+import 'package:flutter/material.dart';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+class DefaultButton extends StatefulWidget {
|
|
6
|
+ //点击回调
|
|
7
|
+ final GestureTapCallback onPressed;
|
|
8
|
+ final String text;
|
|
9
|
+ final EdgeInsetsGeometry margin;
|
|
10
|
+ final double width;
|
|
11
|
+ final double height;
|
|
12
|
+ final double? fontSize;
|
|
13
|
+ final Color backColor;
|
|
14
|
+ final Color color;
|
|
15
|
+
|
|
16
|
+ EdgeInsetsGeometry marginDefault =
|
|
17
|
+ const EdgeInsets.fromLTRB(0, 90.0, 0, 30); //按钮默认的margin值
|
|
18
|
+
|
|
19
|
+ DefaultButton({
|
|
20
|
+ Key? key,
|
|
21
|
+ required this.onPressed,
|
|
22
|
+ required this.text,
|
|
23
|
+ required this.margin,
|
|
24
|
+ required this.width,
|
|
25
|
+ required this.height,
|
|
26
|
+ this.fontSize,
|
|
27
|
+ required this.backColor,
|
|
28
|
+ required this.color,
|
|
29
|
+ }) : super(key: key);
|
|
30
|
+
|
|
31
|
+ @override
|
|
32
|
+ State createState() {
|
|
33
|
+ if (margin == null) {
|
|
34
|
+ return _DefaultButtonState(onPressed, text, marginDefault,width,height,fontSize,backColor,color);
|
|
35
|
+ }
|
|
36
|
+ return _DefaultButtonState(onPressed, text, margin,width,height,fontSize,backColor,color);
|
|
37
|
+ }
|
|
38
|
+}
|
|
39
|
+
|
|
40
|
+class _DefaultButtonState extends State<DefaultButton> {
|
|
41
|
+ //点击回调
|
|
42
|
+ final GestureTapCallback onPressed;
|
|
43
|
+ final String text;
|
|
44
|
+ final EdgeInsetsGeometry margin;
|
|
45
|
+ final double width;
|
|
46
|
+ final double height;
|
|
47
|
+ final double? fontSize;
|
|
48
|
+ final Color backColor;
|
|
49
|
+ final Color color;
|
|
50
|
+ _DefaultButtonState(
|
|
51
|
+ this.onPressed,
|
|
52
|
+ this.text,
|
|
53
|
+ this.margin,
|
|
54
|
+ this.width,
|
|
55
|
+ this.height,
|
|
56
|
+ this.fontSize,
|
|
57
|
+ this.backColor,
|
|
58
|
+ this.color
|
|
59
|
+ );
|
|
60
|
+
|
|
61
|
+ @override
|
|
62
|
+ Widget build(BuildContext context) {
|
|
63
|
+ Widget _SectionBtn = Container(
|
|
64
|
+ margin: margin,
|
|
65
|
+ child: SizedBox(
|
|
66
|
+ width: width,
|
|
67
|
+ height: height,
|
|
68
|
+ child: RaisedButton(
|
|
69
|
+ color: backColor,
|
|
70
|
+ disabledColor: const Color(0xF5F6F7ff),
|
|
71
|
+ disabledTextColor: const Color(0xF5F6F7ff),
|
|
72
|
+ colorBrightness: Brightness.dark,
|
|
73
|
+ shape:
|
|
74
|
+ RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
|
|
75
|
+ child: Text(text,style: TextStyle(
|
|
76
|
+ fontSize: fontSize,
|
|
77
|
+ color: color,
|
|
78
|
+ ),),
|
|
79
|
+ textColor: Colors.white,
|
|
80
|
+ onPressed: onPressed,
|
|
81
|
+ ),
|
|
82
|
+ ),
|
|
83
|
+ );
|
|
84
|
+
|
|
85
|
+ return _SectionBtn;
|
|
86
|
+ }
|
|
87
|
+
|
|
88
|
+}
|
|
89
|
+
|