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 text = super.text(param ?? toolValue?.value) ?? '';
  final iconData = super.iconData(param);
  final enabled = super.enabled(param);
  final options = this.options(param);

  final textStyle = this.textStyle ??
      TextStyle(
        color: fontColor ?? theme.colorScheme.onSurface,
        fontSize: fontSize,
        shadows: textShadow
            ? [
                Shadow(
                  offset: const Offset(1, 1),
                  color: theme.colorScheme.shadow.withValues(alpha: 0.8),
                  blurRadius: 2,
                ),
                Shadow(
                  offset: const Offset(-1, -1),
                  color: Colors.white.withValues(alpha: 0.8),
                  blurRadius: 2,
                )
              ]
            : null,
      );

  final buttonStyle = TextButton.styleFrom(
    shape: const RoundedRectangleBorder(
      borderRadius: BorderRadius.zero,
    ),
  );

  Widget label = Text(
    text,
    style: textStyle,
  );

  final icon = super.icon(param) ??
      (iconData != null
          ? Icon(
              iconData,
              size: iconSize,
              color: iconColor ??
                  textStyle.color ??
                  fontColor ??
                  theme.colorScheme.onSurface,
            )
          : null);

  final onPressed = super.onPressed != null && enabled //
      ? () => super.onPressed!(param)
      : null;

  if (options != null &&
      options.isNotEmpty &&
      onOption != null &&
      (options.length > 1 || options.first != text)) {
    return _TextOptionsButton(
      label: label,
      options: options,
      onOption: onOption!,
      textStyle: textStyle,
      buttonStyle: buttonStyle,
      height: _height,
      icon: icon,
      iconSize: iconSize,
      animateDown: animateDown,
      onPressed: onPressed,
      onInit: onInit,
      onDispose: onDispose,
    );
  } else {
    return _TextButton(
      label: label,
      buttonStyle: buttonStyle,
      icon: icon,
      onPressed: onPressed,
      height: _height,
      onInit: onInit,
      onDispose: onDispose,
    );
  }
}