Issue
I’m trying to get the input for a radio button group but I can’t find anywhere any examples or explanations of how to. All the ones I end up finding is deprecated or does not work 🙁
What I wan’t is this:
The form will have 4 radio button groups and when submit is pressed I wan’t to get the information from those 4 groups then do something with it. But I can’t find anywhere a good way of doing it 🙁
Solution
Tried it and works
<input type="radio" id="r1" name="rate" value="Fixed Rate"> Fixed Rate
<input type="radio" id="r2" name="rate" value="Variable Rate"> Variable Rate
<input type="radio" id="r3" name="rate" value="Multi Rate" checked="checked">
.
main () {
querySelectorAll('input[name=rate]').onClick.listen(clickHandler);
}
void clickHandler(MouseEvent e) {
// two different ways of accessing the current value
print('target: ${(e.target as InputElement).value}');
print('checked: ${(querySelector('input[name=rate]:checked') as InputElement).value}');
}
Answered By – Günter Zöchbauer
Answer Checked By – Cary Denson (FlutterFixes Admin)