MaterialButton constructor Null safety
- {Key? key,
- required VoidCallback? onPressed,
- VoidCallback? onLongPress,
- ValueChanged<
bool> ? onHighlightChanged, - MouseCursor? mouseCursor,
- ButtonTextTheme? textTheme,
- Color? textColor,
- Color? disabledTextColor,
- Color? color,
- Color? disabledColor,
- Color? focusColor,
- Color? hoverColor,
- Color? highlightColor,
- Color? splashColor,
- Brightness? colorBrightness,
- double? elevation,
- double? focusElevation,
- double? hoverElevation,
- double? highlightElevation,
- double? disabledElevation,
- EdgeInsetsGeometry? padding,
- VisualDensity? visualDensity,
- ShapeBorder? shape,
- Clip clipBehavior = Clip.none,
- FocusNode? focusNode,
- bool autofocus = false,
- MaterialTapTargetSize? materialTapTargetSize,
- Duration? animationDuration,
- double? minWidth,
- double? height,
- bool enableFeedback = true,
- 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);