disabled static method

Widget disabled({
  1. Key? key,
  2. required Widget child,
  3. double? width,
  4. double? height,
  5. ZeroSizeType buttonSizeType = ZeroSizeType.medium,
  6. ZeroButtonRadiusType buttonRadiusType = ZeroButtonRadiusType.rectangle,
  7. ZeroButtonStyle? style,
})

Implementation

static Widget disabled({
  Key? key,

  /// [child] is the widget that will be displayed on the button
  required Widget child,

  /// [width] is the width for [ZeroButton]
  /// if this value is null, widget will be sized to fit its contents
  double? width,

  /// [height] is the height for [ZeroButton]
  /// if this value is null, the default height get from [defaultButtonHeight] which is the value based on [buttonSizeType]
  double? height,
  ZeroSizeType buttonSizeType = ZeroSizeType.medium,

  /// [buttonRadiusType] is the type of radius for [ZeroButton]
  /// [ZeroButtonRadiusType.rectangle] is the type of radius for [ZeroButton] that has rectangle shape
  /// [ZeroButtonRadiusType.rounded] is the type of radius for [ZeroButton] that has rounded shape
  /// [ZeroButtonRadiusType.curved] is the type of radius for [ZeroButton] that has curved shape
  ZeroButtonRadiusType buttonRadiusType = ZeroButtonRadiusType.rectangle,

  /// [style] for customizing button style
  /// if this value is null, the default style will be used
  ZeroButtonStyle? style,
}) {
  return Builder(builder: (context) {
    final theme = context.theme;

    /// [disabledDefaultStyle] is the default style for [ZeroButton.disabled]
    final ZeroButtonStyle disabledDefaultStyle = ZeroButtonStyle(
      textStyle:
          style?.textStyle?.copyWith(fontSize: buttonSizeType.fontSize),
      elevation: 0,
      fixedSize: (width != null)
          ? Size(width, height ?? buttonSizeType.defaultButtonHeight)
          : null,
      padding: buttonSizeType.padding,
      shape: RoundedRectangleBorder(
        side: BorderSide(
          color: theme.disabledColor.withOpacity(0.5),
          width: 1,
        ),
        borderRadius: buttonRadiusSize(buttonRadiusType),
      ),
    );

    /// [style] is the style for [ZeroButton]
    final adaptiveStyle = disabledDefaultStyle.merge(style);
    final textStyle =
        (theme.typography.button ?? DefaultTextStyle.of(context).style)
            .copyWith(fontSize: buttonSizeType.fontSize)
            .merge(adaptiveStyle.textStyle)
            .copyWith(color: adaptiveStyle.disabledForegroundColor);

    return ZeroButton._(
      key: key,
      onPressed: null,
      style: adaptiveStyle.copyWith(
        backgroundColor: adaptiveStyle.disabledBackgroundColor,
        foregroundColor: adaptiveStyle.disabledForegroundColor,
      ),
      child: Padding(
        padding: const EdgeInsets.all(0),
        child: IconTheme(
          data: IconTheme.of(context)
              .copyWith(color: adaptiveStyle.disabledForegroundColor),
          child: DefaultTextStyle(
            style: textStyle,
            child: child,
          ),
        ),
      ),
    );
  });
}