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
2f1e7cf6
Unverified
Commit
2f1e7cf6
authored
May 07, 2019
by
Shi-Hao Hong
Committed by
GitHub
May 07, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added state management docs/sample to SwitchListTile (#32147)
* Added documentation to SwitchListTile
parent
f5674d70
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
12 deletions
+23
-12
switch_list_tile.dart
packages/flutter/lib/src/material/switch_list_tile.dart
+23
-12
No files found.
packages/flutter/lib/src/material/switch_list_tile.dart
View file @
2f1e7cf6
...
...
@@ -11,14 +11,19 @@ import 'theme_data.dart';
// Examples can assume:
// void setState(VoidCallback fn) { }
// bool _
lights
;
// bool _
isSelected
;
enum
_SwitchListTileType
{
material
,
adaptive
}
/// A [ListTile] with a [Switch]. In other words, a switch with a label.
///
/// The entire list tile is interactive: tapping anywhere in the tile toggles
/// the switch.
/// the switch. Tapping and dragging the [Switch] also triggers the [onChanged]
/// callback.
///
/// To ensure that [onChanged] correctly triggers, the state passed
/// into [value] must be properly managed. This is typically done by invoking
/// [State.setState] in [onChanged] to toggle the state value.
///
/// The [value], [onChanged], [activeColor], [activeThumbImage], and
/// [inactiveThumbImage] properties of this widget are identical to the
...
...
@@ -41,18 +46,24 @@ enum _SwitchListTileType { material, adaptive }
/// To show the [SwitchListTile] as disabled, pass null as the [onChanged]
/// callback.
///
/// {@tool sample}
/// {@tool sample
--template=stateful_widget_scaffold
}
///
/// This widget shows a switch that, when toggled, changes the state of a [bool]
/// member field called `_lights`.
///
/// ```dart
/// SwitchListTile(
/// title: const Text('Lights'),
/// value: _lights,
/// onChanged: (bool value) { setState(() { _lights = value; }); },
/// secondary: const Icon(Icons.lightbulb_outline),
/// )
/// bool _lights = false;
///
/// Widget build(BuildContext context) {
/// return Center(
/// child: SwitchListTile(
/// title: const Text('Lights'),
/// value: _lights,
/// onChanged: (bool value) { setState(() { _lights = value; }); },
/// secondary: const Icon(Icons.lightbulb_outline),
/// ),
/// );
/// }
/// ```
/// {@end-tool}
///
...
...
@@ -149,13 +160,13 @@ class SwitchListTile extends StatelessWidget {
///
/// ```dart
/// SwitchListTile(
/// value: _
lights
,
/// value: _
isSelected
,
/// onChanged: (bool newValue) {
/// setState(() {
/// _
lights
= newValue;
/// _
isSelected
= newValue;
/// });
/// },
/// title: Text('
Lights
'),
/// title: Text('
Selection
'),
/// )
/// ```
final
ValueChanged
<
bool
>
onChanged
;
...
...
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