-
Notifications
You must be signed in to change notification settings - Fork 2
/
radio.dart
48 lines (41 loc) · 1.21 KB
/
radio.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import 'package:flutter/material.dart';
class RadioExample extends StatefulWidget {
const RadioExample({Key key}) : super(key: key);
@override
State<StatefulWidget> createState() => RadioExampleState();
}
class RadioExampleState extends State<RadioExample> {
int _index = 1;
String _value = '';
final List<DummyItem> _emotions = [
DummyItem(index: 1, value: "option1"),
DummyItem(index: 2, value: "option2"),
DummyItem(index: 3, value: "option3"),
DummyItem(index: 4, value: "option4")
];
@override
Widget build(BuildContext context) {
return Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: _emotions
.map((item) => Radio(
groupValue: _index,
value: item.index,
onChanged: (val) {
setState(() {
_index = val;
_value = item.value;
});
print("ITEM : $_index with VALUE : $_value");
},
))
.toList()),
);
}
}
class DummyItem {
int index;
String value;
DummyItem({this.index, this.value});
}