SwitchListTile.adaptive constructor

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

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,
  this.activeColor,
  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 = false,
  this.dense,
  this.contentPadding,
  this.secondary,
  this.selected = false,
  this.controlAffinity = ListTileControlAffinity.platform,
  this.shape,
  this.selectedTileColor,
  this.visualDensity,
  this.enableFeedback,
  this.hoverColor,
}) : _switchListTileType = _SwitchListTileType.adaptive,
     assert(!isThreeLine || subtitle != null),
     assert(activeThumbImage != null || onActiveThumbImageError == null),
     assert(inactiveThumbImage != null || onInactiveThumbImageError == null);