Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 342a91c

Browse files
εΈƒε±€
1 parent baf2cab commit 342a91c

File tree

4 files changed

+59
-38
lines changed

4 files changed

+59
-38
lines changed

β€Žexample/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ showListViewDialog(BuildContext context) {
140140
YYListViewDialogListTile(context);
141141
}),
142142
makeTextButton("listRadio", () {
143-
YYListViewDialogListButton(context);
143+
YYListViewDialogListRadio(context);
144144
}),
145145
],
146146
),

β€Žlib/components/listview_dialog.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ YYDialog YYListViewDialogListTile(BuildContext context) {
139139
..show();
140140
}
141141

142-
YYDialog YYListViewDialogListButton(BuildContext context) {
142+
YYDialog YYListViewDialogListRadio(BuildContext context) {
143143
return YYDialog().build(context)
144144
..width = 280
145145
..borderRadius = 4.0

β€Žlib/flutter_custom_dialog.dart

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:flutter_custom_dialog/components/bean/dialog_item.dart';
33

44
import 'components/bean/dialog_gravity.dart';
5+
import 'flutter_custom_dialog_widget.dart';
56

67
class YYDialog {
78
//================================εΌΉηͺ—ε±žζ€§======================================
@@ -162,45 +163,13 @@ class YYDialog {
162163
Color activeColor,
163164
Function(int) onClickItemListener,
164165
}) {
165-
var _groupValue = 0;
166166
return this.widget(
167167
Container(
168168
height: height,
169-
child: ListView.builder(
170-
padding: EdgeInsets.all(0.0),
171-
shrinkWrap: true,
172-
itemCount: items.length,
173-
itemBuilder: (BuildContext context, int index) {
174-
return Material(
175-
color: Colors.white,
176-
child: InkWell(
177-
child: ListTile(
178-
onTap: () {
179-
if (onClickItemListener != null) {
180-
onClickItemListener(index);
181-
}
182-
},
183-
contentPadding: items[index].padding ?? EdgeInsets.all(0.0),
184-
leading: Radio(
185-
value: index,
186-
groupValue: _groupValue,
187-
onChanged: (int value) {
188-
_groupValue = value;
189-
},
190-
activeColor: activeColor,
191-
),
192-
title: Text(
193-
items[index].text ?? "",
194-
style: TextStyle(
195-
color: items[index].color ?? null,
196-
fontSize: items[index].fontSize ?? null,
197-
fontWeight: items[index].fontWeight ?? null,
198-
),
199-
),
200-
),
201-
),
202-
);
203-
},
169+
child: YYRadioListTile(
170+
items: items,
171+
activeColor: activeColor,
172+
onChanged: onClickItemListener,
204173
),
205174
),
206175
);
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+
import 'components/bean/dialog_item.dart';
4+
5+
class YYRadioListTile extends StatefulWidget {
6+
YYRadioListTile({
7+
Key key,
8+
this.items,
9+
this.activeColor,
10+
this.onChanged,
11+
}) : assert(items != null),
12+
super(key: key);
13+
14+
List<RadioItem> items;
15+
Color activeColor;
16+
Function(int) onChanged;
17+
18+
@override
19+
State<StatefulWidget> createState() {
20+
return YYRadioListTileState();
21+
}
22+
}
23+
24+
class YYRadioListTileState extends State<YYRadioListTile> {
25+
var groupId = 0;
26+
27+
@override
28+
Widget build(BuildContext context) {
29+
return ListView.builder(
30+
padding: EdgeInsets.all(0.0),
31+
shrinkWrap: true,
32+
itemCount: widget.items.length,
33+
itemBuilder: (BuildContext context, int index) {
34+
return Material(
35+
color: Colors.white,
36+
child: RadioListTile(
37+
title: Text(widget.items[index].text),
38+
value: index,
39+
groupValue: groupId,
40+
activeColor: widget.activeColor,
41+
onChanged: (int value) {
42+
setState(() {
43+
widget.onChanged(value);
44+
groupId = value;
45+
});
46+
},
47+
),
48+
);
49+
},
50+
);
51+
}
52+
}

0 commit comments

Comments
(0)

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /