UiButton constructor

UiButton({
  1. Key? key,
  2. String? label,
  3. Widget? icon,
  4. required VoidCallback? onPressed,
  5. Color? backgroundColor,
  6. Color? foregroundColor,
  7. double borderRadius = 6,
  8. double elevation = 2,
  9. EdgeInsetsGeometry? padding,
  10. TextStyle? labelStyle,
  11. bool expand = false,
  12. String? tooltip,
  13. Color? borderColor,
  14. Gradient? gradient,
})

Implementation

factory UiButton({
  Key? key,
  String? label,
  Widget? icon,
  required VoidCallback? onPressed,
  Color? backgroundColor,
  Color? foregroundColor,
  double borderRadius = 6,
  double elevation = 2,
  EdgeInsetsGeometry? padding,
  TextStyle? labelStyle,
  bool expand = false,
  String? tooltip,
  Color? borderColor,
  Gradient? gradient,
}) {
  return UiButton._internal(
    key: key,
    label: label,
    icon: icon,
    onPressed: onPressed,
    expand: expand,
    tooltip: tooltip,
    type: _UiButtonType.elevated,
    borderColor: borderColor,
    gradient: gradient,
    style: ElevatedButton.styleFrom(
      backgroundColor: gradient == null
          ? (backgroundColor ?? primary)
          : Colors.transparent,
      foregroundColor: foregroundColor ?? white,
      elevation: elevation,
      padding:
          padding ?? const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
      shape: RoundedRectangleBorder(
        side: borderColor != null
            ? BorderSide(color: borderColor, width: 1.2)
            : BorderSide.none,
        borderRadius: BorderRadius.circular(borderRadius),
      ),
      textStyle: labelStyle ??
          const TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
    ),
  );
}