Mention setState in onChanged docs. (#6442)
Add some docs to explain how to use setState() wiht Checkbox, Radio, Slider, and Switch. Based on experience of usability study participant P1.
This commit is contained in:
@@ -58,6 +58,21 @@ class Checkbox extends StatefulWidget {
|
||||
/// value.
|
||||
///
|
||||
/// If null, the checkbox will be displayed as disabled.
|
||||
///
|
||||
/// The callback provided to onChanged should update the state of the parent
|
||||
/// [StatefulWidget] using the [State.setState] method, so that the parent
|
||||
/// gets rebuilt; for example:
|
||||
///
|
||||
/// ```dart
|
||||
/// new Checkbox(
|
||||
/// value: _throwShotAway,
|
||||
/// onChanged: (bool newValue) {
|
||||
/// setState(() {
|
||||
/// _throwShotAway = newValue;
|
||||
/// });
|
||||
/// },
|
||||
/// ),
|
||||
/// ```
|
||||
final ValueChanged<bool> onChanged;
|
||||
|
||||
/// The color to use when this checkbox is checked.
|
||||
|
||||
@@ -70,6 +70,22 @@ class Radio<T> extends StatefulWidget {
|
||||
/// radio button with the new [groupValue].
|
||||
///
|
||||
/// If null, the radio button will be displayed as disabled.
|
||||
///
|
||||
/// The callback provided to onChanged should update the state of the parent
|
||||
/// [StatefulWidget] using the [State.setState] method, so that the parent
|
||||
/// gets rebuilt; for example:
|
||||
///
|
||||
/// ```dart
|
||||
/// new Radio<SingingCharacter>(
|
||||
/// value: SingingCharacter.lafayette,
|
||||
/// groupValue: _character,
|
||||
/// onChanged: (SingingCharacter newValue) {
|
||||
/// setState(() {
|
||||
/// _character = newValue;
|
||||
/// });
|
||||
/// },
|
||||
/// ),
|
||||
/// ```
|
||||
final ValueChanged<T> onChanged;
|
||||
|
||||
/// The color to use when this radio button is selected.
|
||||
|
||||
@@ -78,6 +78,25 @@ class Slider extends StatefulWidget {
|
||||
/// value.
|
||||
///
|
||||
/// If null, the slider will be displayed as disabled.
|
||||
///
|
||||
/// The callback provided to onChanged should update the state of the parent
|
||||
/// [StatefulWidget] using the [State.setState] method, so that the parent
|
||||
/// gets rebuilt; for example:
|
||||
///
|
||||
/// ```dart
|
||||
/// new Slider(
|
||||
/// value: _duelCommandment.toDouble(),
|
||||
/// min: 1.0,
|
||||
/// max: 10.0,
|
||||
/// divisions: 10,
|
||||
/// label: '$_duelCommandment',
|
||||
/// onChanged: (double newValue) {
|
||||
/// setState(() {
|
||||
/// _duelCommandment = newValue.round();
|
||||
/// });
|
||||
/// },
|
||||
/// ),
|
||||
/// ```
|
||||
final ValueChanged<double> onChanged;
|
||||
|
||||
/// The minium value the user can select.
|
||||
|
||||
@@ -61,6 +61,21 @@ class Switch extends StatefulWidget {
|
||||
/// value.
|
||||
///
|
||||
/// If null, the switch will be displayed as disabled.
|
||||
///
|
||||
/// The callback provided to onChanged should update the state of the parent
|
||||
/// [StatefulWidget] using the [State.setState] method, so that the parent
|
||||
/// gets rebuilt; for example:
|
||||
///
|
||||
/// ```dart
|
||||
/// new Switch(
|
||||
/// value: _giveVerse,
|
||||
/// onChanged: (bool newValue) {
|
||||
/// setState(() {
|
||||
/// _giveVerse = newValue;
|
||||
/// });
|
||||
/// },
|
||||
/// ),
|
||||
/// ```
|
||||
final ValueChanged<bool> onChanged;
|
||||
|
||||
/// The color to use when this switch is on.
|
||||
|
||||
Reference in New Issue
Block a user