Switch: Add an interactive example (#103045)

* `Switch`: Add an interactive examples

* Update docs

* Update doc
This commit is contained in:
Taha Tesser
2022-05-25 11:40:31 +03:00
committed by GitHub
parent 680a8192b0
commit 97452d1a10
5 changed files with 197 additions and 0 deletions

View File

@@ -44,6 +44,20 @@ enum _SwitchType { material, adaptive }
///
/// Requires one of its ancestors to be a [Material] widget.
///
/// {@tool dartpad}
/// This example shows a toggleable [Switch]. When the thumb slides to the other
/// side of the track, the switch is toggled between on/off.
///
/// ** See code in examples/api/lib/material/switch/switch.0.dart **
/// {@end-tool}
///
/// {@tool dartpad}
/// This example shows how to customize [Switch] using [MaterialStateProperty]
/// switch properties.
///
/// ** See code in examples/api/lib/material/switch/switch.1.dart **
/// {@end-tool}
///
/// See also:
///
/// * [SwitchListTile], which combines this widget with a [ListTile] so that
@@ -51,6 +65,8 @@ enum _SwitchType { material, adaptive }
/// * [Checkbox], another widget with similar semantics.
/// * [Radio], for selecting among a set of explicit values.
/// * [Slider], for selecting a value in a range.
/// * [MaterialStateProperty], an interface for objects that "resolve" to
/// different values depending on a widget's material state.
/// * <https://material.io/design/components/selection-controls.html#switches>
class Switch extends StatelessWidget {
/// Creates a Material Design switch.