Skip to content

Commit dedc4c3

Browse files
committed
functionality changes in GFRadio
1 parent bb32d99 commit dedc4c3

File tree

2 files changed

+39
-19
lines changed

2 files changed

+39
-19
lines changed

example/lib/main_temp.dart

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,33 @@ class _MyHomePageState extends State<MyHomePage>
197197
onChanged: (val) {
198198
print('val $val');
199199
setState(() {
200-
groupValue = val;
200+
groupValue = 0;
201+
});
202+
print('radio $groupValue $val');
203+
},
204+
activeIcon: const Icon(
205+
Icons.check,
206+
size: 20,
207+
color: GFColors.DARK,
208+
),
209+
// inactiveIcon: const Icon(Icons.close, size: 20, color: GFColors.DARK,),
210+
// custombgColor: GFColors.SUCCESS,
211+
),
212+
213+
GFRadioButton(
214+
size: GFSize.SMALL,
215+
type: GFRadioButtonType.basic,
216+
radioColor: GFColors.SUCCESS,
217+
// activebgColor: GFColors.ALT,
218+
// inactivebgColor: GFColors.PRIMARY,
219+
// activeBorderColor: GFColors.DANGER,
220+
// inactiveBorderColor: GFColors.DARK,
221+
value: 1,
222+
groupValue: groupValue,
223+
onChanged: (val) {
224+
print('val $val');
225+
setState(() {
226+
groupValue = 1;
201227
});
202228
print('radio $groupValue $val');
203229
},

lib/components/radio/gf_radio.dart

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,18 @@ class _GFRadioButtonState extends State<GFRadioButton> {
9999
super.initState();
100100
}
101101

102-
103-
void _handleChanged(bool selected) {
102+
void _handle(){
104103
bool selected = false;
105104
if(widget.value == widget.groupValue){
106-
selected = true;
105+
selected = false;
107106
}
107+
print('sel $selected');
108+
_handleChanged(selected);
109+
}
110+
111+
112+
void _handleChanged(bool selected) {
113+
108114
if (selected == null) {
109115
widget.onChanged(null);
110116
return;
@@ -114,28 +120,16 @@ class _GFRadioButtonState extends State<GFRadioButton> {
114120
}
115121
}
116122

123+
124+
117125
@override
118126
Widget build(BuildContext context) => FocusableActionDetector(
119127
focusNode: widget.focusNode,
120128
autofocus: widget.autofocus,
121129
enabled: enabled,
122130
child: InkWell(
123131
canRequestFocus: enabled,
124-
onTap: widget.onChanged != null ?
125-
() {
126-
bool selected = false;
127-
if(widget.value == widget.groupValue){
128-
selected = widget.value;
129-
}
130-
if (selected == null) {
131-
widget.onChanged(null);
132-
}
133-
if (selected) {
134-
widget.onChanged(widget.value);
135-
}
136-
return selected;
137-
} : null,
138-
// onTap: enabled ? _handleChanged : null,
132+
onTap: enabled ? _handle : null,
139133
child: Container(
140134
height: widget.size,
141135
width: widget.size,

0 commit comments

Comments
 (0)