widget method

Widget widget(
  1. BuildContext context
)
override

Implementation

widget(context) {
  if (type == NikuButtonType.Filled)
    return (label != null && icon != null)
        ? FilledButton.icon(
            label: label!,
            icon: icon!,
            onPressed: enable ? onPressed : null,
            onLongPress: enable ? onLongPress : null,
            style: style?.value,
            focusNode: focusNode,
            autofocus: autofocus ?? false,
            clipBehavior: clipBehavior ?? Clip.none,
          )
        : FilledButton(
            child: child,
            onPressed: enable ? onPressed : null,
            onLongPress: enable ? onLongPress : null,
            style: style?.value,
            focusNode: focusNode,
            autofocus: autofocus ?? false,
            clipBehavior: clipBehavior ?? Clip.none,
          );

  if (type == NikuButtonType.Tonal)
    return (label != null && icon != null)
        ? FilledButton.tonalIcon(
            label: label!,
            icon: icon!,
            onPressed: enable ? onPressed : null,
            onLongPress: enable ? onLongPress : null,
            style: style?.value,
            focusNode: focusNode,
            autofocus: autofocus ?? false,
            clipBehavior: clipBehavior ?? Clip.none,
          )
        : FilledButton.tonal(
            child: child,
            onPressed: enable ? onPressed : null,
            onLongPress: enable ? onLongPress : null,
            style: style?.value,
            focusNode: focusNode,
            autofocus: autofocus ?? false,
            clipBehavior: clipBehavior ?? Clip.none,
          );

  if (type == NikuButtonType.Elevated)
    return (label != null && icon != null)
        ? ElevatedButton.icon(
            label: label!,
            icon: icon!,
            onPressed: enable ? onPressed : null,
            onLongPress: enable ? onLongPress : null,
            style: style?.value,
            focusNode: focusNode,
            autofocus: autofocus ?? false,
            clipBehavior: clipBehavior ?? Clip.none,
          )
        : ElevatedButton(
            child: child,
            onPressed: enable ? onPressed : null,
            onLongPress: enable ? onLongPress : null,
            style: style?.value,
            focusNode: focusNode,
            autofocus: autofocus ?? false,
            clipBehavior: clipBehavior ?? Clip.none,
          );

  if (type == NikuButtonType.Outlined)
    return (label != null && icon != null)
        ? OutlinedButton.icon(
            label: label!,
            icon: icon!,
            onPressed: enable ? onPressed : null,
            onLongPress: enable ? onLongPress : null,
            style: style?.value,
            focusNode: focusNode,
            autofocus: autofocus ?? false,
            clipBehavior: clipBehavior ?? Clip.none,
          )
        : OutlinedButton(
            child: child,
            onPressed: enable ? onPressed : null,
            onLongPress: enable ? onLongPress : null,
            style: style?.value,
            focusNode: focusNode,
            autofocus: autofocus ?? false,
            clipBehavior: clipBehavior ?? Clip.none,
          );

  return (label != null && icon != null)
      ? TextButton.icon(
          label: label!,
          icon: icon!,
          onPressed: enable ? onPressed : null,
          onLongPress: enable ? onLongPress : null,
          style: style?.value,
          focusNode: focusNode,
          autofocus: autofocus ?? false,
          clipBehavior: clipBehavior ?? Clip.none,
        )
      : TextButton(
          child: child,
          onPressed: enable ? onPressed : null,
          onLongPress: enable ? onLongPress : null,
          style: style?.value,
          focusNode: focusNode,
          autofocus: autofocus ?? false,
          clipBehavior: clipBehavior ?? Clip.none,
        );
}