Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
1da7f1b9
Unverified
Commit
1da7f1b9
authored
Apr 24, 2019
by
Shi-Hao Hong
Committed by
GitHub
Apr 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Radio Documentation with Example (#31294)
parent
c7a09a41
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
6 deletions
+59
-6
radio.dart
packages/flutter/lib/src/material/radio.dart
+59
-6
No files found.
packages/flutter/lib/src/material/radio.dart
View file @
1da7f1b9
...
...
@@ -21,11 +21,64 @@ const double _kInnerRadius = 4.5;
/// be selected. The values are of type `T`, the type parameter of the [Radio]
/// class. Enums are commonly used for this purpose.
///
/// The radio button itself does not maintain any state. Instead, when the state
/// of the radio button changes, the widget calls the [onChanged] callback.
/// Most widget that use a radio button will listen for the [onChanged]
/// callback and rebuild the radio button with a new [groupValue] to update the
/// visual appearance of the radio button.
/// The radio button itself does not maintain any state. Instead, selecting the
/// radio invokes the [onChanged] callback, passing [value] as a parameter. If
/// [groupValue] and [value] match, this radio will be selected. Most widgets
/// will respond to [onChanged] by calling [State.setState] to update the
/// radio button's [groupValue].
///
/// {@tool snippet --template=stateful_widget_scaffold}
///
/// Here is an example of Radio widgets wrapped in ListTiles, which is similar
/// to what you could get with the RadioListTile widget.
///
/// The currently selected character is passed into `groupValue`, which is
/// maintained by the example's `State`. In this case, the first `Radio`
/// will start off selected because `_character` is initialized to
/// `SingingCharacter.lafayette`.
///
/// If the second radio button is pressed, the example's state is updated
/// with `setState`, updating `_character` to `SingingCharacter.jefferson`.
/// This causes the buttons to rebuild with the updated `groupValue`, and
/// therefore the selection of the second button.
///
/// ```dart preamble
/// enum SingingCharacter { lafayette, jefferson }
/// ```
///
/// ```dart
/// SingingCharacter _character = SingingCharacter.lafayette;
///
/// Widget build(BuildContext context) {
/// return Center(
/// child: Column(
/// children: <Widget>[
/// ListTile(
/// title: const Text('Lafayette'),
/// leading: Radio(
/// value: SingingCharacter.lafayette,
/// groupValue: _character,
/// onChanged: (SingingCharacter value) {
/// setState(() { _character = value; });
/// },
/// ),
/// ),
/// ListTile(
/// title: const Text('Thomas Jefferson'),
/// leading: Radio(
/// value: SingingCharacter.jefferson,
/// groupValue: _character,
/// onChanged: (SingingCharacter value) {
/// setState(() { _character = value; });
/// },
/// ),
/// ),
/// ],
/// ),
/// );
/// }
/// ```
/// {@end-tool}
///
/// Requires one of its ancestors to be a [Material] widget.
///
...
...
@@ -62,7 +115,7 @@ class Radio<T> extends StatefulWidget {
/// The value represented by this radio button.
final
T
value
;
/// The currently selected value for
this
group of radio buttons.
/// The currently selected value for
a
group of radio buttons.
///
/// This radio button is considered selected if its [value] matches the
/// [groupValue].
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment