CustomActionButton.iconOnly constructor

CustomActionButton.iconOnly({
  1. Key? key,
  2. required VoidCallback? onPressed,
  3. required Widget icon,
  4. ButtonType baseType = ButtonType.elevated,
  5. Color? backgroundColor,
  6. Color? foregroundColor,
  7. Color? shadowColor,
  8. Color? splashColor,
  9. Color? disabledBackgroundColor,
  10. Color? disabledBorderColor,
  11. Color? disabledForegroundColor,
  12. Color? borderColor,
  13. Gradient? backgroundGradient,
  14. Gradient? disabledBackgroundGradient,
  15. double? size = 48.0,
  16. double? iconSize,
  17. EdgeInsetsGeometry? margin,
  18. OutlinedBorder? shape,
  19. double? elevation,
  20. InteractiveInkFeatureFactory? splashFactory,
  21. MaterialTapTargetSize tapTargetSize = MaterialTapTargetSize.padded,
})

Creates a circular button that displays only an icon.

This factory is designed to behave like IconButton, with a circular shape and a larger tap target by default.

Implementation

factory CustomActionButton.iconOnly({
  Key? key,
  required VoidCallback? onPressed,
  required Widget icon,
  ButtonType baseType = ButtonType.elevated,
  Color? backgroundColor,
  Color? foregroundColor,
  Color? shadowColor,
  Color? splashColor,
  Color? disabledBackgroundColor,
  Color? disabledBorderColor,
  Color? disabledForegroundColor,
  Color? borderColor,
  Gradient? backgroundGradient,
  Gradient? disabledBackgroundGradient,
  double? size = 48.0,
  double? iconSize,
  EdgeInsetsGeometry? margin,
  OutlinedBorder? shape,
  double? elevation,
  InteractiveInkFeatureFactory? splashFactory,
  MaterialTapTargetSize tapTargetSize = MaterialTapTargetSize.padded,
}) {
  final Widget themedIcon = IconTheme.merge(
    data: IconThemeData(color: foregroundColor, size: iconSize),
    child: icon,
  );

  return CustomActionButton(
    key: key,
    buttonType: baseType,
    onPressed: onPressed,
    backgroundColor: backgroundColor,
    foregroundColor: foregroundColor,
    shadowColor: shadowColor,
    splashColor: splashColor,
    disabledBackgroundColor: disabledBackgroundColor,
    disabledBorderColor: disabledBorderColor,
    disabledForegroundColor: disabledForegroundColor,
    borderColor: borderColor,
    backgroundGradient: backgroundGradient,
    disabledBackgroundGradient: disabledBackgroundGradient,
    width: size,
    height: size,
    minHeight: 0.0,
    padding: EdgeInsets.zero,
    margin: margin,
    shape: shape ?? const CircleBorder(),
    elevation: elevation,
    splashFactory: splashFactory,
    tapTargetSize: tapTargetSize,
    child: themedIcon,
  );
}