RawMaterialButton constructor Null safety
- {Key? key,
- required VoidCallback? onPressed,
- VoidCallback? onLongPress,
- ValueChanged<
bool> ? onHighlightChanged, - MouseCursor? mouseCursor,
- TextStyle? textStyle,
- Color? fillColor,
- Color? focusColor,
- Color? hoverColor,
- Color? highlightColor,
- Color? splashColor,
- double elevation = 2.0,
- double focusElevation = 4.0,
- double hoverElevation = 4.0,
- double highlightElevation = 8.0,
- double disabledElevation = 0.0,
- EdgeInsetsGeometry padding = EdgeInsets.zero,
- VisualDensity visualDensity = VisualDensity.standard,
- BoxConstraints constraints = const BoxConstraints(minWidth: 88.0, minHeight: 36.0),
- ShapeBorder shape = const RoundedRectangleBorder(),
- Duration animationDuration = kThemeChangeDuration,
- Clip clipBehavior = Clip.none,
- FocusNode? focusNode,
- bool autofocus = false,
- MaterialTapTargetSize? materialTapTargetSize,
- Widget? child,
- bool enableFeedback = true}
Create a button based on Semantics, Material, and InkWell widgets.
The shape, elevation, focusElevation, hoverElevation, highlightElevation, disabledElevation, padding, constraints, autofocus, and clipBehavior arguments must not be null. Additionally, elevation, focusElevation, hoverElevation, highlightElevation, and disabledElevation must be non-negative.
Implementation
const RawMaterialButton({
super.key,
required this.onPressed,
this.onLongPress,
this.onHighlightChanged,
this.mouseCursor,
this.textStyle,
this.fillColor,
this.focusColor,
this.hoverColor,
this.highlightColor,
this.splashColor,
this.elevation = 2.0,
this.focusElevation = 4.0,
this.hoverElevation = 4.0,
this.highlightElevation = 8.0,
this.disabledElevation = 0.0,
this.padding = EdgeInsets.zero,
this.visualDensity = VisualDensity.standard,
this.constraints = const BoxConstraints(minWidth: 88.0, minHeight: 36.0),
this.shape = const RoundedRectangleBorder(),
this.animationDuration = kThemeChangeDuration,
this.clipBehavior = Clip.none,
this.focusNode,
this.autofocus = false,
MaterialTapTargetSize? materialTapTargetSize,
this.child,
this.enableFeedback = true,
}) : materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded,
assert(shape != 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),
assert(padding != null),
assert(constraints != null),
assert(animationDuration != null),
assert(clipBehavior != null),
assert(autofocus != null);