Skip to content

Commit 30017f7

Browse files
samsam
authored andcommitted
feat: RaisedButton
1 parent 46fbd4e commit 30017f7

File tree

3 files changed

+157
-3
lines changed

3 files changed

+157
-3
lines changed
Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,57 @@
1-
## **文档完善中**
1+
## **RaisedButton**
2+
>
3+
RaisedButton 凸起按钮
4+
5+
### 构造方法
6+
``` dart
7+
RaisedButton({
8+
Key key,
9+
@required VoidCallback onPressed,
10+
ValueChanged<bool> onHighlightChanged,
11+
ButtonTextTheme textTheme,
12+
Color textColor,
13+
Color disabledTextColor,
14+
Color color,
15+
Color disabledColor,
16+
Color highlightColor,
17+
Color splashColor,
18+
Brightness colorBrightness,
19+
double elevation,
20+
double highlightElevation,
21+
double disabledElevation,
22+
EdgeInsetsGeometry padding,
23+
ShapeBorder shape,
24+
Clip clipBehavior = Clip.none,
25+
MaterialTapTargetSize materialTapTargetSize,
26+
Duration animationDuration,
27+
Widget child,
28+
})
29+
```
30+
31+
### 属性介绍
32+
* onPressed: 点击回调
33+
* textColor:文本颜色
34+
* disabledTextColor:禁用文本颜色
35+
* color:按钮颜色
36+
* disabledColor: 禁用按钮颜色
37+
* highlightColor:长按按钮颜色
38+
* splashColor: 点击按钮水波纹颜色
39+
* elevation: 按钮下面阴影
40+
* highlightElevation:阴影大小
41+
* disabledElevation:禁止阴影
42+
* padding:按钮填充区域
43+
* shape:按钮形状
44+
* child:按钮中的Widget
45+
46+
### 高级用法
47+
按钮形状
48+
* BeveledRectangleBorder 带斜角的长方形边框
49+
* CircleBorder 圆形边框
50+
* RoundedRectangleBorder 圆角矩形
51+
* StadiumBorder 两端是半圆的边框
52+
53+
设置按钮形状常用属性
54+
* side:用来设置边线(颜色、宽度等)
55+
* borderRadius:用来设置圆角
56+
57+
使用RaisedButton.icon可以创建图标(icon)和标签(label)的widget文本按钮

lib/widget/common/raisedbutton/demo.dart

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Index extends StatefulWidget {
66
}
77

88
class _IndexState extends State<Index> {
9+
var params = 0.0;
910
@override
1011
void initState() {
1112
super.initState();
@@ -18,7 +19,104 @@ class _IndexState extends State<Index> {
1819
title: Text('RaisedButton'),
1920
),
2021
body: Center(
21-
child: Text('更新中'),
22+
child: Wrap(
23+
alignment: WrapAlignment.spaceEvenly,
24+
children: <Widget>[
25+
RaisedButton(
26+
onPressed: () {
27+
setState(() {
28+
params == 0.0 ? params = 10.0 : params = 0.0;
29+
});
30+
},
31+
child: Text('BeveledRectangleBorder'),
32+
textColor: Colors.white,
33+
textTheme: ButtonTextTheme.normal,
34+
color: Theme.of(context).primaryColor,
35+
splashColor: Colors.pink,
36+
highlightColor: Colors.pink,
37+
elevation: 2.0,
38+
highlightElevation: 8.0,
39+
padding: EdgeInsets.all(10.0),
40+
shape: BeveledRectangleBorder(
41+
side: BorderSide(
42+
color: Colors.green
43+
),
44+
borderRadius: BorderRadius.all(Radius.circular(params))
45+
)
46+
),
47+
RaisedButton(
48+
onPressed: () {
49+
setState(() {
50+
params == 0.0 ? params = 10.0 : params = 0.0;
51+
});
52+
},
53+
child: Text('RoundedRectangleBorder'),
54+
textColor: Colors.white,
55+
textTheme: ButtonTextTheme.normal,
56+
color: Theme.of(context).primaryColor,
57+
splashColor: Colors.pink,
58+
highlightColor: Colors.pink,
59+
elevation: 2.0,
60+
highlightElevation: 8.0,
61+
padding: EdgeInsets.all(10.0),
62+
shape: RoundedRectangleBorder(
63+
side: BorderSide(
64+
color: Colors.green
65+
),
66+
borderRadius: BorderRadius.circular(params)
67+
)
68+
),
69+
RaisedButton(
70+
onPressed: () {
71+
setState(() {
72+
params == 0.0 ? params = 10.0 : params = 0.0;
73+
});
74+
},
75+
child: Text('CircleBorder'),
76+
textColor: Colors.white,
77+
textTheme: ButtonTextTheme.normal,
78+
color: Theme.of(context).primaryColor,
79+
splashColor: Colors.pink,
80+
highlightColor: Colors.pink,
81+
elevation: 2.0,
82+
highlightElevation: 8.0,
83+
padding: EdgeInsets.all(30.0),
84+
shape: CircleBorder(
85+
side: BorderSide(
86+
color: Colors.green
87+
),
88+
)
89+
),
90+
RaisedButton(
91+
onPressed: () {
92+
setState(() {
93+
params == 0.0 ? params = 10.0 : params = 0.0;
94+
});
95+
},
96+
child: Text('StadiumBorder'),
97+
textColor: Colors.white,
98+
textTheme: ButtonTextTheme.normal,
99+
color: Theme.of(context).primaryColor,
100+
splashColor: Colors.pink,
101+
highlightColor: Colors.pink,
102+
elevation: 2.0,
103+
highlightElevation: 8.0,
104+
padding: EdgeInsets.all(10.0),
105+
shape: StadiumBorder(
106+
side: BorderSide(
107+
color: Colors.green
108+
)
109+
)
110+
),
111+
RaisedButton.icon(
112+
icon: Icon(Icons.android, size: 28.0,),
113+
label: Text('RaisedButton.icon'),
114+
onPressed: () {},
115+
textColor: Colors.white,
116+
color: Theme.of(context).primaryColor,
117+
)
118+
],
119+
),
22120
),
23121
);
24122
}

readme/widget_progress.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Flutter UI
5858
│ ├─image 【✔️ v1.0】
5959
│ ├─listtile 【✔️ v1.0】
6060
│ ├─placeholder
61-
│ ├─raisedbutton
61+
│ ├─raisedbutton 【✔️ v1.0】
6262
│ ├─rawimage
6363
│ ├─stepper 【✔️ v1.0】
6464
│ ├─text 【✔️ v1.0】

0 commit comments

Comments
 (0)