MaterialButton constructor Null safety

const MaterialButton(
  1. {Key? key,
  2. required VoidCallback? onPressed,
  3. VoidCallback? onLongPress,
  4. ValueChanged<bool>? onHighlightChanged,
  5. MouseCursor? mouseCursor,
  6. ButtonTextTheme? textTheme,
  7. Color? textColor,
  8. Color? disabledTextColor,
  9. Color? color,
  10. Color? disabledColor,
  11. Color? focusColor,
  12. Color? hoverColor,
  13. Color? highlightColor,
  14. Color? splashColor,
  15. Brightness? colorBrightness,
  16. double? elevation,
  17. double? focusElevation,
  18. double? hoverElevation,
  19. double? highlightElevation,
  20. double? disabledElevation,
  21. EdgeInsetsGeometry? padding,
  22. VisualDensity? visualDensity,
  23. ShapeBorder? shape,
  24. Clip clipBehavior = Clip.none,
  25. FocusNode? focusNode,
  26. bool autofocus = false,
  27. MaterialTapTargetSize? materialTapTargetSize,
  28. Duration? animationDuration,
  29. double? minWidth,
  30. double? height,
  31. bool enableFeedback = true,
  32. Widget? child}
)

Creates a Material Design button.

To create a custom Material button consider using TextButton, ElevatedButton, or OutlinedButton.

The autofocus and clipBehavior arguments must not be null. Additionally, elevation, hoverElevation, focusElevation, highlightElevation, and disabledElevation must be non-negative, if specified.

Implementation

const MaterialButton({
  super.key,
  required this.onPressed,
  this.onLongPress,
  this.onHighlightChanged,
  this.mouseCursor,
  this.textTheme,
  this.textColor,
  this.disabledTextColor,
  this.color,
  this.disabledColor,
  this.focusColor,
  this.hoverColor,
  this.highlightColor,
  this.splashColor,
  this.colorBrightness,
  this.elevation,
  this.focusElevation,
  this.hoverElevation,
  this.highlightElevation,
  this.disabledElevation,
  this.padding,
  this.visualDensity,
  this.shape,
  this.clipBehavior = Clip.none,
  this.focusNode,
  this.autofocus = false,
  this.materialTapTargetSize,
  this.animationDuration,
  this.minWidth,
  this.height,
  this.enableFeedback = true,
  this.child,
}) : assert(clipBehavior != null),
     assert(autofocus != null),
     assert(elevation == null || elevation >= 0.0),
     assert(focusElevation == null || focusElevation >= 0.0),
     assert(hoverElevation == null || hoverElevation >= 0.0),
     assert(highlightElevation == null || highlightElevation >= 0.0),
     assert(disabledElevation == null || disabledElevation >= 0.0);