ClearButton constructor

const ClearButton(
  1. TextEditingController _controller, {
  2. Widget icon = defaultIcon,
  3. VoidCallback? onPressed,
  4. double? iconSize,
  5. VisualDensity? visualDensity,
  6. EdgeInsetsGeometry? padding,
  7. AlignmentGeometry? alignment,
  8. double? splashRadius,
  9. Color? color,
  10. Color? focusColor,
  11. Color? hoverColor,
  12. Color? highlightColor,
  13. Color? splashColor,
  14. Color? disabledColor,
  15. ValueChanged<bool>? onHover,
  16. VoidCallback? onLongPress,
  17. MouseCursor? mouseCursor,
  18. FocusNode? focusNode,
  19. bool autofocus = false,
  20. String? tooltip,
  21. bool? enableFeedback,
  22. BoxConstraints? constraints,
  23. ButtonStyle? style,
  24. bool? isSelected,
  25. Widget? selectedIcon,
  26. Key? key,
  27. MaterialStatesController? statesController,
  28. Widget whenEmptyChild = UiConstants.placeholder,
  29. Curve firstCurve = UiConstants.switchOutCurve,
  30. Curve secondCurve = UiConstants.switchInCurve,
  31. Curve sizeCurve = UiConstants.switchOutCurve,
  32. Duration duration = UiConstants.duration,
  33. AnimatedCrossFadeBuilder layoutBuilder = AnimatedCrossFade.defaultLayoutBuilder,
  34. bool excludeBottomFocus = true,
  35. Duration? reverseDuration,
})

Constructor for the ClearButton class.

TextEditingController is the only mandatory field here and it's a text editing controller to listen to. Other parameters are simply passed to the super constructor of IconButton and AnimatedCrossFade. When the text editing controller's text is empty, the whenEmptyChild is shown instead of the IconButton.

Implementation

const ClearButton(
  this._controller, {
  super.icon = defaultIcon,
  super.onPressed,
  super.iconSize,
  super.visualDensity,
  super.padding,
  super.alignment,
  super.splashRadius,
  super.color,
  super.focusColor,
  super.hoverColor,
  super.highlightColor,
  super.splashColor,
  super.disabledColor,
  super.onHover,
  super.onLongPress,
  super.mouseCursor,
  super.focusNode,
  super.autofocus,
  super.tooltip,
  super.enableFeedback,
  super.constraints,
  super.style,
  super.isSelected,
  super.selectedIcon,
  super.key,
  super.statesController,
  this.whenEmptyChild = UiConstants.placeholder,
  this.firstCurve = UiConstants.switchOutCurve,
  this.secondCurve = UiConstants.switchInCurve,
  this.sizeCurve = UiConstants.switchOutCurve,
  this.duration = UiConstants.duration,
  this.layoutBuilder = AnimatedCrossFade.defaultLayoutBuilder,
  this.excludeBottomFocus = true,
  this.reverseDuration,
});