diff --git a/packages/flutter/lib/src/material/checkbox.dart b/packages/flutter/lib/src/material/checkbox.dart index b75021adf0..072fbe0b4c 100644 --- a/packages/flutter/lib/src/material/checkbox.dart +++ b/packages/flutter/lib/src/material/checkbox.dart @@ -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 onChanged; /// The color to use when this checkbox is checked. diff --git a/packages/flutter/lib/src/material/radio.dart b/packages/flutter/lib/src/material/radio.dart index 8c8220dd3c..f5cadb0530 100644 --- a/packages/flutter/lib/src/material/radio.dart +++ b/packages/flutter/lib/src/material/radio.dart @@ -70,6 +70,22 @@ class Radio 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( + /// value: SingingCharacter.lafayette, + /// groupValue: _character, + /// onChanged: (SingingCharacter newValue) { + /// setState(() { + /// _character = newValue; + /// }); + /// }, + /// ), + /// ``` final ValueChanged onChanged; /// The color to use when this radio button is selected. diff --git a/packages/flutter/lib/src/material/slider.dart b/packages/flutter/lib/src/material/slider.dart index 51a1cc8821..7630c87722 100644 --- a/packages/flutter/lib/src/material/slider.dart +++ b/packages/flutter/lib/src/material/slider.dart @@ -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 onChanged; /// The minium value the user can select. diff --git a/packages/flutter/lib/src/material/switch.dart b/packages/flutter/lib/src/material/switch.dart index 41af96ffb6..29cafc22f2 100644 --- a/packages/flutter/lib/src/material/switch.dart +++ b/packages/flutter/lib/src/material/switch.dart @@ -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 onChanged; /// The color to use when this switch is on.