SwitchListTile.adaptive constructor

const SwitchListTile.adaptive({
  1. Key? key,
  2. required bool value,
  3. required ValueChanged<bool>? onChanged,
  4. @Deprecated('Use activeThumbColor or activeTrackColor 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. bool? applyCupertinoTheme,
  26. Color? tileColor,
  27. Widget? title,
  28. Widget? subtitle,
  29. bool? isThreeLine,
  30. bool? dense,
  31. EdgeInsetsGeometry? contentPadding,
  32. Widget? secondary,
  33. bool selected = false,
  34. ListTileControlAffinity? controlAffinity,
  35. ShapeBorder? shape,
  36. Color? selectedTileColor,
  37. VisualDensity? visualDensity,
  38. bool? enableFeedback,
  39. Color? hoverColor,
  40. bool internalAddSemanticForOnTap = false,
})

Creates a Material ListTile with an adaptive Switch, following Material design's Cross-platform guidelines.

This widget uses Switch.adaptive to change the graphics of the switch component based on the ambient ThemeData.platform. On iOS and macOS, a CupertinoSwitch will be used. On other platforms a Material design Switch will be used.

If a CupertinoSwitch is created, the following parameters are ignored: activeTrackColor, inactiveThumbColor, inactiveTrackColor, activeThumbImage, inactiveThumbImage.

Implementation

const SwitchListTile.adaptive({
  super.key,
  required this.value,
  required this.onChanged,
  @Deprecated(
    'Use activeThumbColor or activeTrackColor 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.applyCupertinoTheme,
  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.adaptive,
     assert(isThreeLine != true || subtitle != null),
     assert(activeThumbImage != null || onActiveThumbImageError == null),
     assert(inactiveThumbImage != null || onInactiveThumbImageError == null);