buildWidget method

  1. @override
Widget buildWidget(
  1. BuildContext context, {
  2. T? param,
  3. Axis orientation = Axis.horizontal,
  4. bool compact = false,
  5. bool floating = false,
})
override

Implementation

@override
Widget buildWidget(
  BuildContext context, {
  T? param,
  Axis orientation = Axis.horizontal,
  bool compact = false,
  bool floating = false,
}) {
  final theme = Theme.of(context);
  final icon = super.icon(param);
  final iconData = super.iconData(param);
  final enabled = super.enabled(param);
  final onPressed = super.onPressed != null && enabled //
      ? () => super.onPressed!(param)
      : null;

  final isPressed = this.isPressed != null //
      ? this.isPressed!(param)
      : false;

  return ElevatedButton(
    key: super.key,
    onPressed: onPressed,
    style: style == null
        ? ElevatedButton.styleFrom(
            padding: const EdgeInsets.all(0),
            shape: const RoundedRectangleBorder(
              borderRadius: BorderRadius.all(Radius.circular(5)),
            ),
            iconColor: isPressed
                ? this.pressedIconColor ??
                    theme.buttonTheme.colorScheme?.onPrimary
                        .withValues(alpha: 0.5)
                : this.iconColor,
            backgroundColor: isPressed
                ? this.pressedBackgroundColor ??
                    theme.buttonTheme.colorScheme?.primary
                        .withValues(alpha: 0.5)
                : this.backgroundColor,
            maximumSize: size,
            minimumSize: size,
          )
        : style!.copyWith(
            maximumSize: WidgetStateProperty.all(size),
            minimumSize: WidgetStateProperty.all(size),
          ),
    child: icon ?? Icon(iconData),
  );
}