defaultToggleStyleButtonBuilder function

Widget defaultToggleStyleButtonBuilder(
  1. BuildContext context,
  2. NotusAttribute attribute,
  3. IconData icon,
  4. bool isToggled,
  5. VoidCallback? onPressed,
)

Default builder for toggle style buttons.

Implementation

Widget defaultToggleStyleButtonBuilder(
  BuildContext context,
  NotusAttribute attribute,
  IconData icon,
  bool isToggled,
  VoidCallback? onPressed,
) {
  final theme = Theme.of(context);
  final isEnabled = onPressed != null;
  final iconColor = isEnabled
      ? isToggled
          ? theme.primaryIconTheme.color
          : theme.iconTheme.color
      : theme.disabledColor;
  final fillColor = isToggled ? theme.toggleableActiveColor : theme.canvasColor;
  return ZIconButton(
    highlightElevation: 0,
    hoverElevation: 0,
    size: 32,
    icon: Icon(icon, size: 18, color: iconColor),
    fillColor: fillColor,
    onPressed: onPressed,
  );
}