Add some docs to StatefulBuilder (#31291)
This commit is contained in:
parent
81af5a76dd
commit
26d7f502a9
@ -6249,6 +6249,45 @@ typedef StatefulWidgetBuilder = Widget Function(BuildContext context, StateSette
|
|||||||
|
|
||||||
/// A platonic widget that both has state and calls a closure to obtain its child widget.
|
/// A platonic widget that both has state and calls a closure to obtain its child widget.
|
||||||
///
|
///
|
||||||
|
/// The [StateSetter] function passed to the [builder] is used to invoke a
|
||||||
|
/// rebuild instead of a typical [State]'s [State.setState].
|
||||||
|
///
|
||||||
|
/// Since the [builder] is re-invoked when the [StateSetter] is called, any
|
||||||
|
/// variables that represents state should be kept outside the [builder] function.
|
||||||
|
///
|
||||||
|
/// {@tool sample}
|
||||||
|
///
|
||||||
|
/// This example shows using an inline StatefulBuilder that rebuilds and that
|
||||||
|
/// also has state.
|
||||||
|
///
|
||||||
|
/// ```dart
|
||||||
|
/// await showDialog<void>(
|
||||||
|
/// context: context,
|
||||||
|
/// builder: (BuildContext context) {
|
||||||
|
/// int selectedRadio = 0;
|
||||||
|
/// return AlertDialog(
|
||||||
|
/// content: StatefulBuilder(
|
||||||
|
/// builder: (BuildContext context, StateSetter setState) {
|
||||||
|
/// return Column(
|
||||||
|
/// mainAxisSize: MainAxisSize.min,
|
||||||
|
/// children: List<Widget>.generate(4, (int index) {
|
||||||
|
/// return Radio<int>(
|
||||||
|
/// value: index,
|
||||||
|
/// groupValue: selectedRadio,
|
||||||
|
/// onChanged: (int value) {
|
||||||
|
/// setState(() => selectedRadio = value);
|
||||||
|
/// },
|
||||||
|
/// );
|
||||||
|
/// }),
|
||||||
|
/// );
|
||||||
|
/// },
|
||||||
|
/// ),
|
||||||
|
/// );
|
||||||
|
/// },
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
|
/// {@end-tool}
|
||||||
|
///
|
||||||
/// See also:
|
/// See also:
|
||||||
///
|
///
|
||||||
/// * [Builder], the platonic stateless widget.
|
/// * [Builder], the platonic stateless widget.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user