SwitchListTile constructor

const SwitchListTile({
  1. Key? key,
  2. required bool value,
  3. required ValueChanged<bool>? onChanged,
  4. @Deprecated('Use activeThumbColor instead. ' 'This feature was deprecated after v3.31.0-2.0.pre.') Color? activeColor,
  5. Color? activeThumbColor,
  6. Color? activeTrackColor,
  7. Color? inactiveThumbColor,
  8. Color? inactiveTrackColor,
  9. ImageProvider<Object>? activeThumbImage,
  10. ImageErrorListener? onActiveThumbImageError,
  11. ImageProvider<Object>? inactiveThumbImage,
  12. ImageErrorListener? onInactiveThumbImageError,
  13. MaterialStateProperty<Color?>? thumbColor,
  14. MaterialStateProperty<Color?>? trackColor,
  15. MaterialStateProperty<Color?>? trackOutlineColor,
  16. MaterialStateProperty<Icon?>? thumbIcon,
  17. MaterialTapTargetSize? materialTapTargetSize,
  18. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  19. MouseCursor? mouseCursor,
  20. MaterialStateProperty<Color?>? overlayColor,
  21. double? splashRadius,
  22. FocusNode? focusNode,
  23. ValueChanged<bool>? onFocusChange,
  24. bool autofocus = false,
  25. Color? tileColor,
  26. Widget? title,
  27. Widget? subtitle,
  28. bool? isThreeLine,
  29. bool? dense,
  30. EdgeInsetsGeometry? contentPadding,
  31. Widget? secondary,
  32. bool selected = false,
  33. ListTileControlAffinity? controlAffinity,
  34. ShapeBorder? shape,
  35. Color? selectedTileColor,
  36. VisualDensity? visualDensity,
  37. bool? enableFeedback,
  38. Color? hoverColor,
  39. bool internalAddSemanticForOnTap = false,
})

Creates a combination of a list tile and a switch.

The switch tile itself does not maintain any state. Instead, when the state of the switch changes, the widget calls the onChanged callback. Most widgets that use a switch will listen for the onChanged callback and rebuild the switch tile with a new value to update the visual appearance of the switch.

The following arguments are required:

  • value determines whether this switch is on or off.
  • onChanged is called when the user toggles the switch on or off.

Implementation

const SwitchListTile({
  super.key,
  required this.value,
  required this.onChanged,
  @Deprecated(
    'Use activeThumbColor instead. '
    'This feature was deprecated after v3.31.0-2.0.pre.',
  )
  this.activeColor,
  this.activeThumbColor,
  this.activeTrackColor,
  this.inactiveThumbColor,
  this.inactiveTrackColor,
  this.activeThumbImage,
  this.onActiveThumbImageError,
  this.inactiveThumbImage,
  this.onInactiveThumbImageError,
  this.thumbColor,
  this.trackColor,
  this.trackOutlineColor,
  this.thumbIcon,
  this.materialTapTargetSize,
  this.dragStartBehavior = DragStartBehavior.start,
  this.mouseCursor,
  this.overlayColor,
  this.splashRadius,
  this.focusNode,
  this.onFocusChange,
  this.autofocus = false,
  this.tileColor,
  this.title,
  this.subtitle,
  this.isThreeLine,
  this.dense,
  this.contentPadding,
  this.secondary,
  this.selected = false,
  this.controlAffinity,
  this.shape,
  this.selectedTileColor,
  this.visualDensity,
  this.enableFeedback,
  this.hoverColor,
  this.internalAddSemanticForOnTap = false,
}) : _switchListTileType = _SwitchListTileType.material,
     applyCupertinoTheme = false,
     assert(activeThumbImage != null || onActiveThumbImageError == null),
     assert(inactiveThumbImage != null || onInactiveThumbImageError == null),
     assert(isThreeLine != true || subtitle != null);