File tree Expand file tree Collapse file tree 4 files changed +27
-6
lines changed Expand file tree Collapse file tree 4 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -63,54 +63,63 @@ var radioItems = [
6363 RadioItem (
6464 padding: EdgeInsets .only (left: 6.0 ),
6565 text: "None" ,
66+ value: 1 ,
6667 color: Colors .black,
6768 fontSize: 16.0 ,
6869 ),
6970 RadioItem (
7071 padding: EdgeInsets .only (left: 6.0 ),
7172 text: "Callisto" ,
73+ value: 11 ,
7274 color: Colors .black,
7375 fontSize: 16.0 ,
7476 ),
7577 RadioItem (
7678 padding: EdgeInsets .only (left: 6.0 ),
7779 text: "Ganymede" ,
80+ value: 7 ,
7881 color: Colors .black,
7982 fontSize: 16.0 ,
8083 ),
8184 RadioItem (
8285 padding: EdgeInsets .only (left: 6.0 ),
8386 text: "Luna" ,
87+ value: 6 ,
8488 color: Colors .black,
8589 fontSize: 16.0 ,
8690 ),
8791 RadioItem (
8892 padding: EdgeInsets .only (left: 6.0 ),
8993 text: "Oberon" ,
94+ value: 4 ,
9095 color: Colors .black,
9196 fontSize: 16.0 ,
9297 ),
9398 RadioItem (
9499 padding: EdgeInsets .only (left: 6.0 ),
95100 text: "Phobos" ,
101+ value: 18 ,
96102 color: Colors .black,
97103 fontSize: 16.0 ,
98104 ),
99105 RadioItem (
100106 padding: EdgeInsets .only (left: 6.0 ),
101107 text: "Dione" ,
108+ value: 16 ,
102109 color: Colors .black,
103110 fontSize: 16.0 ,
104111 ),
105112 RadioItem (
106113 padding: EdgeInsets .only (left: 6.0 ),
107114 text: "James" ,
115+ value: 10 ,
108116 color: Colors .black,
109117 fontSize: 16.0 ,
110118 ),
111119 RadioItem (
112120 padding: EdgeInsets .only (left: 6.0 ),
113121 text: "Lina" ,
122+ value: 25 ,
114123 color: Colors .black,
115124 fontSize: 16.0 ,
116125 ),
@@ -151,6 +160,7 @@ YYDialog YYListViewDialogListRadio() {
151160 ..listViewOfRadioButton (
152161 items: radioItems,
153162 height: 370 ,
163+ intialValue: 7 ,
154164 activeColor: Colors .deepPurpleAccent,
155165 onClickItemListener: (index) {
156166 var radioItem = radioItems[index];
Original file line number Diff line number Diff line change @@ -206,6 +206,7 @@ class YYDialog {
206206 List <RadioItem > items,
207207 double height,
208208 Color activeColor,
209+ int intialValue,
209210 Function (int ) onClickItemListener,
210211 }) {
211212 Size size = MediaQuery .of (context).size;
@@ -219,6 +220,7 @@ class YYDialog {
219220 ),
220221 child: YYRadioListTile (
221222 items: items,
223+ intialValue: intialValue,
222224 activeColor: activeColor,
223225 onChanged: onClickItemListener,
224226 ),
@@ -572,6 +574,7 @@ class RadioItem {
572574 RadioItem ({
573575 this .padding,
574576 this .text,
577+ this .value,
575578 this .color,
576579 this .fontSize,
577580 this .fontWeight,
@@ -580,6 +583,7 @@ class RadioItem {
580583
581584 EdgeInsets padding;
582585 String text;
586+ int value;
583587 Color color;
584588 double fontSize;
585589 FontWeight fontWeight;
Original file line number Diff line number Diff line change @@ -7,13 +7,15 @@ class YYRadioListTile extends StatefulWidget {
77 YYRadioListTile ({
88 Key key,
99 this .items,
10+ this .intialValue = 0 ,
1011 this .activeColor,
1112 this .onChanged,
1213 }) : assert (items != null ),
1314 super (key: key);
1415
1516 final List <RadioItem > items;
1617 final Color activeColor;
18+ final intialValue;
1719 final Function (int ) onChanged;
1820
1921 @override
@@ -24,26 +26,31 @@ class YYRadioListTile extends StatefulWidget {
2426
2527class YYRadioListTileState extends State <YYRadioListTile > {
2628 var groupId = 0 ;
29+ var selectedItem = - 1 ;
2730
2831 @override
2932 Widget build (BuildContext context) {
33+ if (selectedItem == - 1 ) {
34+ selectedItem = widget.intialValue != null ? widget.intialValue : 0 ;
35+ }
3036 return ListView .builder (
3137 padding: EdgeInsets .all (0.0 ),
3238 shrinkWrap: true ,
3339 itemCount: widget.items.length,
3440 itemBuilder: (BuildContext context, int index) {
41+ var radioItem = widget.items[index];
3542 return Material (
3643 color: Colors .white,
3744 child: RadioListTile (
38- title: Text (widget.items[index] .text),
39- value: index,
40- groupValue: groupId ,
45+ title: Text (radioItem .text),
46+ value: radioItem.value == null ? index : radioItem.value ,
47+ groupValue: selectedItem ,
4148 activeColor: widget.activeColor,
4249 onChanged: (int value) {
4350 setState (() {
44- widget.onChanged (value);
45- groupId = value;
51+ selectedItem = value;
4652 });
53+ widget.onChanged (value);
4754 },
4855 ),
4956 );
Original file line number Diff line number Diff line change 11name : flutter_custom_dialog
22description : Semantic dialog | Made In YY.inc | Welcome to contribute
3- version : 1.0.16
3+ version : 1.0.20
44author :
AndroidHensen <[email protected] > 55homepage : https://github.com/YYFlutter/flutter-custom-dialog.git
66
You can’t perform that action at this time.
0 commit comments