Skip to content

Instantly share code, notes, and snippets.

@ipondroid
Created August 8, 2019 09:04
Show Gist options
  • Select an option

  • Save ipondroid/c95cfbda459b94239e6aa329d30f8422 to your computer and use it in GitHub Desktop.

Select an option

Save ipondroid/c95cfbda459b94239e6aa329d30f8422 to your computer and use it in GitHub Desktop.
class _MyListTiles extends State<MyListTiles> {
var _checkboxValue = false;
var _radioValue = 0;
var _switchValue = false;
@override
Widget build(BuildContext context) {
return ListView(
padding: EdgeInsets.zero,
children: <Widget>[
CheckboxListTile(
value: _checkboxValue,
title: Text('Open source?'),
onChanged: (bool value) {
setState(() { _checkboxValue = value; });
},
secondary: _checkboxValue?Icon(Icons.thumb_up):Icon(Icons.thumb_down),
),
Divider(),
RadioListTile(
title: Text('GOOD'),
value: 1,
groupValue: _radioValue,
onChanged: (int value) {
setState(() { _radioValue = value; });
},
),
RadioListTile(
title: Text('NOT GOOD'),
value: 2,
groupValue: _radioValue,
onChanged: (int value) {
setState(() { _radioValue = value; });
},
),
Divider(),
SwitchListTile(
title: Text('Lights'),
subtitle: Text(_switchValue?'on':'off'),
value: _switchValue,
onChanged: (bool value) {
setState(() { _switchValue = value; });
},
secondary: Icon(Icons.lightbulb_outline),
),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment