defaultStyleOf method

ButtonStyle defaultStyleOf(
  1. BuildContext context
)

Implementation

ButtonStyle defaultStyleOf(BuildContext context) {
  final colors = Theme.of(context).colorScheme;
  return ButtonStyle(
    fixedSize: MaterialStateProperty.all(Size(iconSize, iconSize)),
    foregroundColor: MaterialStateProperty.resolveWith((states) {
      if (states.contains(MaterialState.selected)) {
        if (states.contains(MaterialState.disabled)) {
          return colors.primary.withOpacity(0.38);
        }
        return colors.primary;
      }
      if (states.contains(MaterialState.disabled)) {
        return colors.onSurface.withOpacity(0.38);
      }
      return colors.onSurface.withOpacity(0.8);
    }),
    backgroundColor: MaterialStateProperty.resolveWith((states) {
      if (states.contains(MaterialState.selected)) {
        return colors.onSurface.withOpacity(0.1);
      }
      return null;
    }),
    overlayColor: MaterialStateProperty.resolveWith((states) {
      if (states.contains(MaterialState.selected)) {
        if (states.contains(MaterialState.pressed)) {
          return colors.onSurface.withOpacity(0.12);
        }
        if (states.contains(MaterialState.hovered)) {
          return colors.onSurface.withOpacity(0.08);
        }
        if (states.contains(MaterialState.focused)) {
          return colors.onSurface.withOpacity(0.12);
        }
      }
      if (states.contains(MaterialState.pressed)) {
        return colors.onSurfaceVariant.withOpacity(0.12);
      }
      if (states.contains(MaterialState.hovered)) {
        return colors.onSurfaceVariant.withOpacity(0.08);
      }
      if (states.contains(MaterialState.focused)) {
        return colors.onSurfaceVariant.withOpacity(0.08);
      }
      return null;
    }),
  );
}