styleFrom static method

ButtonStyle styleFrom({
  1. Color? foregroundColor,
  2. Color? backgroundColor,
  3. Color? disabledForegroundColor,
  4. Color? disabledBackgroundColor,
  5. Color? shadowColor,
  6. Color? surfaceTintColor,
  7. Color? iconColor,
  8. Color? disabledIconColor,
  9. double? elevation,
  10. TextStyle? textStyle,
  11. EdgeInsetsGeometry? padding,
  12. Size? minimumSize,
  13. Size? fixedSize,
  14. Size? maximumSize,
  15. BorderSide? side,
  16. OutlinedBorder? shape,
  17. MouseCursor? enabledMouseCursor,
  18. MouseCursor? disabledMouseCursor,
  19. VisualDensity? visualDensity,
  20. MaterialTapTargetSize? tapTargetSize,
  21. Duration? animationDuration,
  22. bool? enableFeedback,
  23. AlignmentGeometry? alignment,
  24. InteractiveInkFeatureFactory? splashFactory,
  25. Color? overlayColor,
})

Implementation

static ButtonStyle styleFrom({
  Color? foregroundColor,
  Color? backgroundColor,
  Color? disabledForegroundColor,
  Color? disabledBackgroundColor,
  Color? shadowColor,
  Color? surfaceTintColor,
  Color? iconColor,
  Color? disabledIconColor,
  double? elevation,
  TextStyle? textStyle,
  EdgeInsetsGeometry? padding,
  Size? minimumSize,
  Size? fixedSize,
  Size? maximumSize,
  BorderSide? side,
  OutlinedBorder? shape,
  MouseCursor? enabledMouseCursor,
  MouseCursor? disabledMouseCursor,
  VisualDensity? visualDensity,
  MaterialTapTargetSize? tapTargetSize,
  Duration? animationDuration,
  bool? enableFeedback,
  AlignmentGeometry? alignment,
  InteractiveInkFeatureFactory? splashFactory,
  Color? overlayColor,
}) {
  final Color? foreground = foregroundColor;
  final Color? disabledForeground = disabledForegroundColor;
  final MaterialStateProperty<Color?>? foregroundColorProp = (foreground == null && disabledForeground == null)
      ? null
      : _MTextButtonDefaultColor(foreground, disabledForeground);
  final MaterialStateProperty<Color?>? backgroundColorProp =
      (backgroundColor == null && disabledBackgroundColor == null)
          ? null
          : disabledBackgroundColor == null
              ? ButtonStyleButton.allOrNull<Color?>(backgroundColor)
              : _MTextButtonDefaultColor(backgroundColor, disabledBackgroundColor);
  MaterialStateProperty<Color?>? effectiveOverlayColor =
      (overlayColor != null || foreground != null) ? _MTextButtonDefaultOverlay(overlayColor ?? foreground!) : null;
  final MaterialStateProperty<Color?>? iconColorProp = (iconColor == null && disabledIconColor == null)
      ? null
      : disabledIconColor == null
          ? ButtonStyleButton.allOrNull<Color?>(iconColor)
          : _MTextButtonDefaultIconColor(iconColor, disabledIconColor);
  final MaterialStateProperty<MouseCursor?> mouseCursor =
      _TextButtonDefaultMouseCursor(enabledMouseCursor, disabledMouseCursor);

  return ButtonStyle(
    textStyle: ButtonStyleButton.allOrNull<TextStyle>(textStyle),
    foregroundColor: foregroundColorProp,
    backgroundColor: backgroundColorProp,
    overlayColor: effectiveOverlayColor,
    shadowColor: ButtonStyleButton.allOrNull<Color>(shadowColor),
    surfaceTintColor: ButtonStyleButton.allOrNull<Color>(surfaceTintColor),
    iconColor: iconColorProp,
    elevation: ButtonStyleButton.allOrNull<double>(elevation),
    padding: ButtonStyleButton.allOrNull<EdgeInsetsGeometry>(padding),
    minimumSize: ButtonStyleButton.allOrNull<Size>(minimumSize),
    fixedSize: ButtonStyleButton.allOrNull<Size>(fixedSize),
    maximumSize: ButtonStyleButton.allOrNull<Size>(maximumSize),
    side: ButtonStyleButton.allOrNull<BorderSide>(side),
    shape: ButtonStyleButton.allOrNull<OutlinedBorder>(shape),
    mouseCursor: mouseCursor,
    visualDensity: visualDensity,
    tapTargetSize: tapTargetSize,
    animationDuration: animationDuration,
    enableFeedback: enableFeedback,
    alignment: alignment,
    splashFactory: splashFactory,
  );
}