Skip to content

Commit cecdd2f

Browse files
committed
feat: Radio
1 parent 814d9ec commit cecdd2f

File tree

9 files changed

+174
-17
lines changed

9 files changed

+174
-17
lines changed

docs/widget/form/radio/index.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
1-
## **文档完善中**
1+
## **Radio**
2+
3+
>
4+
单选按钮
5+
6+
### 构造方法
7+
``` dart
8+
Radio({
9+
Key key,
10+
@required this.value,
11+
@required this.groupValue,
12+
@required this.onChanged,
13+
this.activeColor,
14+
this.materialTapTargetSize,
15+
})
16+
```
17+
18+
### 属性介绍
19+
* value:单选按钮的值
20+
* groupValue:此组单选按钮的当前选定值,当value=groupValue时表示该按钮被选中
21+
* onChanged:选择单选按钮时的回调
22+
* activeColor:选中该按钮的颜色
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## **RadioListTile**
2+
3+
>
4+
单选按钮
5+
6+
### 构造方法
7+
``` dart
8+
Radio({
9+
Key key,
10+
@required this.value,
11+
@required this.groupValue,
12+
@required this.onChanged,
13+
this.activeColor,
14+
this.materialTapTargetSize,
15+
})
16+
```
17+
18+
### 属性介绍
19+
* value:单选按钮的值
20+
* groupValue:此组单选按钮的当前选定值,当value=groupValue时表示该按钮被选中
21+
* onChanged:选择单选按钮时的回调
22+
* activeColor:选中该按钮的颜色

lib/widget/form/index.dart

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import 'checkboxlisttile/index.dart' as CheckboxListTile;
44
import 'slider/index.dart' as Slider;
55
import 'switch/index.dart' as switchExample;
66
import 'switchlisttile/index.dart' as switchListTile;
7+
import 'daypicker/index.dart' as daypicker;
8+
import 'radio/index.dart' as radio;
9+
import 'radiolisttile/index.dart' as radioListTile;
710
import 'textinput/index.dart' as textinput;
811
import 'textfield/index.dart' as textfield;
912
import 'rawkeyboard/index.dart' as rawkeyboard;
10-
import 'radio/index.dart' as radio;
1113
import 'formfield/index.dart' as formfield;
1214
import 'form/index.dart' as form;
13-
import 'daypicker/index.dart' as daypicker;
15+
1416

1517
const nameSpaces = '/form_';
1618

@@ -45,6 +47,16 @@ List widgets = [
4547
code: 58345, // gradient
4648
title: daypicker.Index.title
4749
),
50+
ItemInfo(
51+
widget: radio.Index(),
52+
code: 58693, // local_florist
53+
title: radio.Index.title
54+
),
55+
ItemInfo(
56+
widget: radioListTile.Index(),
57+
code: 58371, // monochrome_photos
58+
title: radioListTile.Index.title
59+
),
4860
ItemInfo(
4961
widget: form.Index(),
5062
code: 59526, // group_work
@@ -55,11 +67,6 @@ List widgets = [
5567
code: 60230, // hot_tub
5668
title: formfield.Index.title
5769
),
58-
ItemInfo(
59-
widget: radio.Index(),
60-
code: 58693, // local_florist
61-
title: radio.Index.title
62-
),
6370
ItemInfo(
6471
widget: rawkeyboard.Index(),
6572
code: 58698, // local_laundry_service

lib/widget/form/radio/demo.dart

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,46 @@ class Index extends StatefulWidget {
66
}
77

88
class _IndexState extends State<Index> {
9+
int _radioValue = 0;
10+
911
@override
1012
void initState() {
1113
super.initState();
1214
}
1315

16+
void _handleRadioValueChanged (int value) {
17+
setState(() {
18+
_radioValue = value;
19+
});
20+
}
21+
1422
@override
1523
Widget build(BuildContext context) {
1624
return Scaffold(
1725
appBar: AppBar(
1826
title: Text('Radio'),
1927
),
20-
body: Center(
21-
child: Text('更新中'),
28+
body: Column(
29+
children: <Widget>[
30+
Radio(
31+
value: 0,
32+
groupValue: _radioValue,
33+
onChanged: _handleRadioValueChanged,
34+
activeColor: Theme.of(context).primaryColor,
35+
),
36+
Radio(
37+
value: 1,
38+
groupValue: _radioValue,
39+
onChanged: _handleRadioValueChanged,
40+
activeColor: Theme.of(context).primaryColor,
41+
),
42+
Radio(
43+
value: 2,
44+
groupValue: _radioValue,
45+
onChanged: _handleRadioValueChanged,
46+
activeColor: Theme.of(context).primaryColor,
47+
),
48+
],
2249
),
2350
);
2451
}

lib/widget/form/radio/index.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:efox_flutter/components/widgetComp.dart' as WidgetComp;
3-
// import 'demo.dart' as Demo;
3+
import 'demo.dart' as Demo;
44

55
class Index extends StatefulWidget {
66
static String title = 'Radio';
@@ -19,7 +19,7 @@ class _IndexState extends State<Index> {
1919
originCodeUrl: Index.originCodeUrl,
2020
mdUrl: Index.mdUrl,
2121
demoChild: [
22-
// Demo.Index(),
22+
Demo.Index(),
2323
],
2424
);
2525
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import 'package:flutter/material.dart';
2+
3+
class Index extends StatefulWidget {
4+
@override
5+
State<StatefulWidget> createState() => _IndexState();
6+
}
7+
8+
class _IndexState extends State<Index> {
9+
int _radioValue = 0;
10+
11+
@override
12+
void initState() {
13+
super.initState();
14+
}
15+
16+
void _handleRadioValueChanged (int value) {
17+
setState(() {
18+
_radioValue = value;
19+
});
20+
}
21+
22+
@override
23+
Widget build(BuildContext context) {
24+
return Scaffold(
25+
appBar: AppBar(
26+
title: Text('Radio'),
27+
),
28+
body: Column(
29+
children: <Widget>[
30+
Radio(
31+
value: 0,
32+
groupValue: _radioValue,
33+
onChanged: _handleRadioValueChanged,
34+
activeColor: Theme.of(context).primaryColor,
35+
),
36+
Radio(
37+
value: 1,
38+
groupValue: _radioValue,
39+
onChanged: _handleRadioValueChanged,
40+
activeColor: Theme.of(context).primaryColor,
41+
),
42+
Radio(
43+
value: 2,
44+
groupValue: _radioValue,
45+
onChanged: _handleRadioValueChanged,
46+
activeColor: Theme.of(context).primaryColor,
47+
),
48+
],
49+
),
50+
);
51+
}
52+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:efox_flutter/components/widgetComp.dart' as WidgetComp;
3+
import 'demo.dart' as Demo;
4+
5+
class Index extends StatefulWidget {
6+
static String title = 'RadioListTile';
7+
static String mdUrl = 'docs/widget/form/radiolisttile/index.md';
8+
static String originCodeUrl = 'https://docs.flutter.io/flutter/material/RadioListTile-class.html';
9+
10+
@override
11+
_IndexState createState() => new _IndexState();
12+
}
13+
14+
class _IndexState extends State<Index> {
15+
@override
16+
Widget build(BuildContext context) {
17+
return WidgetComp.Index(
18+
title: Index.title,
19+
originCodeUrl: Index.originCodeUrl,
20+
mdUrl: Index.mdUrl,
21+
demoChild: [
22+
Demo.Index(),
23+
],
24+
);
25+
}
26+
}

pubspec.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,14 @@ flutter:
8989
- docs/widget/form/checkbox/
9090
- docs/widget/form/checkboxlisttile/
9191
- docs/widget/form/slider/
92+
- docs/widget/form/switch/
93+
- docs/widget/form/switchlisttile/
9294
- docs/widget/form/daypicker/
95+
- docs/widget/form/radio/
96+
- docs/widget/form/radiolisttile/
9397
- docs/widget/form/form/
9498
- docs/widget/form/formfield/
95-
- docs/widget/form/radio/
9699
- docs/widget/form/rawkeyboard/
97-
- docs/widget/form/switch/
98-
- docs/widget/form/switchlisttile/
99100
- docs/widget/form/textfield/
100101
- docs/widget/form/textinput/
101102
- docs/widget/navigator/appbar/

readme.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,15 @@ Flutter UI
125125
├─form
126126
│ ├─checkbox 【✔️ v1.0】
127127
│ ├─checkboxlisttile 【✔️ v1.0】
128+
│ ├─slider 【✔️ v1.0】
128129
│ ├─switch 【✔️ v1.0】
129130
│ ├─switchListTile 【✔️ v1.0】
130131
│ ├─daypicker 【✔️ v1.0】
132+
│ ├─radio 【✔️ v1.0】
133+
│ ├─radioListTile
131134
│ ├─form
132135
│ ├─formfield
133-
│ ├─radio
134136
│ ├─rawkeyboard
135-
│ ├─slider
136137
│ ├─textfield
137138
│ └─textinput
138139
├─gestures

0 commit comments

Comments
 (0)