MaterialStateProperty Docs (#96532)
This commit is contained in:
@@ -161,6 +161,25 @@ class Checkbox extends StatefulWidget {
|
||||
/// * [MaterialState.hovered].
|
||||
/// * [MaterialState.focused].
|
||||
/// * [MaterialState.disabled].
|
||||
///
|
||||
/// {@tool snippet}
|
||||
/// This example resolves the [fillColor] based on the current [MaterialState]
|
||||
/// of the [Checkbox], providing a different [Color] when it is
|
||||
/// [MaterialState.disabled].
|
||||
///
|
||||
/// ```dart
|
||||
/// Checkbox(
|
||||
/// value: true,
|
||||
/// onChanged: (_){},
|
||||
/// fillColor: MaterialStateProperty.resolveWith<Color>((states) {
|
||||
/// if (states.contains(MaterialState.disabled)) {
|
||||
/// return Colors.orange.withOpacity(.32);
|
||||
/// }
|
||||
/// return Colors.orange;
|
||||
/// })
|
||||
/// )
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
/// {@endtemplate}
|
||||
///
|
||||
/// If null, then the value of [activeColor] is used in the selected
|
||||
|
||||
@@ -189,6 +189,26 @@ class Radio<T> extends StatefulWidget {
|
||||
/// * [MaterialState.hovered].
|
||||
/// * [MaterialState.focused].
|
||||
/// * [MaterialState.disabled].
|
||||
///
|
||||
/// {@tool snippet}
|
||||
/// This example resolves the [fillColor] based on the current [MaterialState]
|
||||
/// of the [Radio], providing a different [Color] when it is
|
||||
/// [MaterialState.disabled].
|
||||
///
|
||||
/// ```dart
|
||||
/// Radio<int>(
|
||||
/// value: 1,
|
||||
/// groupValue: 1,
|
||||
/// onChanged: (_){},
|
||||
/// fillColor: MaterialStateProperty.resolveWith<Color>((states) {
|
||||
/// if (states.contains(MaterialState.disabled)) {
|
||||
/// return Colors.orange.withOpacity(.32);
|
||||
/// }
|
||||
/// return Colors.orange;
|
||||
/// })
|
||||
/// )
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
/// {@endtemplate}
|
||||
///
|
||||
/// If null, then the value of [activeColor] is used in the selected state. If
|
||||
|
||||
@@ -229,6 +229,25 @@ class Switch extends StatelessWidget {
|
||||
/// * [MaterialState.hovered].
|
||||
/// * [MaterialState.focused].
|
||||
/// * [MaterialState.disabled].
|
||||
///
|
||||
/// {@tool snippet}
|
||||
/// This example resolves the [thumbColor] based on the current
|
||||
/// [MaterialState] of the [Switch], providing a different [Color] when it is
|
||||
/// [MaterialState.disabled].
|
||||
///
|
||||
/// ```dart
|
||||
/// Switch(
|
||||
/// value: true,
|
||||
/// onChanged: (_) => true,
|
||||
/// thumbColor: MaterialStateProperty.resolveWith<Color>((states) {
|
||||
/// if (states.contains(MaterialState.disabled)) {
|
||||
/// return Colors.orange.withOpacity(.48);
|
||||
/// }
|
||||
/// return Colors.orange;
|
||||
/// }),
|
||||
/// )
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
/// {@endtemplate}
|
||||
///
|
||||
/// If null, then the value of [activeColor] is used in the selected
|
||||
@@ -251,6 +270,25 @@ class Switch extends StatelessWidget {
|
||||
/// * [MaterialState.hovered].
|
||||
/// * [MaterialState.focused].
|
||||
/// * [MaterialState.disabled].
|
||||
///
|
||||
/// {@tool snippet}
|
||||
/// This example resolves the [trackColor] based on the current
|
||||
/// [MaterialState] of the [Switch], providing a different [Color] when it is
|
||||
/// [MaterialState.disabled].
|
||||
///
|
||||
/// ```dart
|
||||
/// Switch(
|
||||
/// value: true,
|
||||
/// onChanged: (_) => true,
|
||||
/// thumbColor: MaterialStateProperty.resolveWith<Color>((states) {
|
||||
/// if (states.contains(MaterialState.disabled)) {
|
||||
/// return Colors.orange.withOpacity(.48);
|
||||
/// }
|
||||
/// return Colors.orange;
|
||||
/// }),
|
||||
/// )
|
||||
/// ```
|
||||
/// {@end-tool}
|
||||
/// {@endtemplate}
|
||||
///
|
||||
/// If null, then the value of [activeTrackColor] is used in the selected
|
||||
|
||||
Reference in New Issue
Block a user