buildButton method

Widget buildButton(
  1. BuildContext context,
  2. Widget child, {
  3. FastButtonEmphasis emphasis = FastButtonEmphasis.low,
  4. ValueChanged<bool>? onHover,
  5. BoxConstraints? constraints,
  6. EdgeInsetsGeometry? padding,
  7. BoxDecoration? decoration,
  8. bool flexible = false,
  9. bool isEnabled = true,
  10. String? semanticLabel,
  11. Color? highlightColor,
  12. Alignment? alignment,
  13. FastButtonSize? size,
  14. VoidCallback? onTap,
  15. Color? focusColor,
  16. Color? hoverColor,
  17. String? tooltip,
  18. Color? color,
  19. Widget? icon,
})

Implementation

Widget buildButton(
  BuildContext context,
  Widget child, {
  FastButtonEmphasis emphasis = FastButtonEmphasis.low,
  ValueChanged<bool>? onHover,
  BoxConstraints? constraints,
  EdgeInsetsGeometry? padding,
  BoxDecoration? decoration,
  bool flexible = false,
  bool isEnabled = true,
  String? semanticLabel,
  Color? highlightColor,
  Alignment? alignment,
  FastButtonSize? size,
  VoidCallback? onTap,
  Color? focusColor,
  Color? hoverColor,
  String? tooltip,
  Color? color,
  Widget? icon,
}) {
  Widget button = Container(
    constraints: constraints ??
        getButtonConstraints(
          context,
          size: size,
          icon: icon,
        ),
    alignment: alignment ?? Alignment.center,
    padding: padding,
    child: child,
  );

  if (!flexible) {
    button = UnconstrainedBox(child: button);
  }

  if (decoration != null) {
    button = Ink(
      decoration: decoration,
      child: button,
    );
  }

  button = FastInkWell(
    highlightColor: getHighlightColor(
      context,
      highlightColor: highlightColor,
      emphasis: emphasis,
      color: color,
      icon: icon,
    ),
    hoverColor: getHoverColor(
      context,
      hoverColor: hoverColor,
      emphasis: emphasis,
      color: color,
      icon: icon,
    ),
    focusColor: focusColor,
    isEnabled: isEnabled,
    onHover: onHover,
    onTap: onTap,
    child: button,
  );

  button = Semantics(
    label: semanticLabel,
    enabled: isEnabled,
    button: true,
    child: button,
  );

  if (tooltip != null) {
    button = FastTooltip(
      message: tooltip,
      child: button,
    );
  }

  return button;
}