如何从单选按钮检索数据?

时间:2019-04-08 16:35:39

标签: flutter radio-button

我有一个数据源(firebase),其中包含每个项目的列表。在颤动中,我要导入列表,并使用数据作为a / b选择用单选按钮填充自定义滚动视图。如何将每个单选按钮选择的动态表单数据转换为变量?还是回到我的数据库?

编辑过的:我想做的是使用var _pick = data [i] .home;将单选按钮选择的值放入列表变量(_pick)中。打印(_pick);

                    new Text("GAME: ${data[i].game} ${data[i].away.toUpperCase()} at ${data[i].home.toUpperCase()} "),

                    RadioListTile<SingleGame>(
                      subtitle: const Text('record 3- 1'),
                      title: new Text("${data[i].home.toUpperCase()}"),
                      controlAffinity: ListTileControlAffinity.trailing,
                      value: SingleGame.$home,
                      groupValue: data[i].selectedValue,
                      activeColor: Colors.green,
                      onChanged: 
                      (SingleGame value) {
                        setState(() {
                          data[i].selectedValue = SingleGame.$home;
                          var _pick =data[i].home; print(_pick);
                          //var _selectedIndex=_pick;
                          //picksList.add(_pick); 
                        });
                      },

                      selected: data[i].selectedValue == SingleGame.$home,
                    ),
                    ////
                    RadioListTile<SingleGame>(
                      subtitle: const Text('record 3- 1'),
                      title: new Text("${data[i].away.toUpperCase()}"),
                      controlAffinity: ListTileControlAffinity.trailing,
                      value: SingleGame.$away,
                      groupValue: data[i].selectedValue, 
                      activeColor: Colors.green,
                      onChanged: (SingleGame value) {
                        setState(() {
                          data[i].selectedValue = SingleGame.$away;
                          var _pick =data[i].away; print(_pick);
                          // _picksList.add(_pick);
                        });
                      },
                      selected: data[i].selectedValue == SingleGame.$away,

                    ),

0 个答案:

没有答案