raisedButtonStyle function
ButtonStyle
raisedButtonStyle({
- Color? primary,
- Color? onPrimary,
- Color? onSurface,
- Color? shadowColor,
- Color? splashColor,
- 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,
Returns a ButtonStyle that is used to make a ElevatedButton look like a deprecated RaisedButton
,
but with given styles.
Implementation
ButtonStyle raisedButtonStyle({
Color? primary,
Color? onPrimary,
Color? onSurface,
Color? shadowColor,
Color? splashColor,
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,
}) {
var style = ElevatedButton.styleFrom(
// fields for RaisedButton
onPrimary: onPrimary ?? Colors.black87,
primary: primary ?? Colors.grey[300],
padding: padding ?? const EdgeInsets.symmetric(horizontal: 16.0),
shape: shape ?? const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(2.0))),
// fields for ElevatedButton
onSurface: onSurface,
shadowColor: shadowColor,
elevation: elevation,
textStyle: textStyle,
minimumSize: minimumSize,
fixedSize: fixedSize,
maximumSize: maximumSize,
side: side,
enabledMouseCursor: enabledMouseCursor,
disabledMouseCursor: disabledMouseCursor,
visualDensity: visualDensity,
tapTargetSize: tapTargetSize,
animationDuration: animationDuration,
enableFeedback: enableFeedback,
alignment: alignment,
splashFactory: splashFactory,
);
if (splashColor != null) {
// add extra splashColor style
style = style.copyWith(
overlayColor: MaterialStateProperty.resolveWith(
(s) => s.contains(MaterialState.pressed) ? splashColor : null,
),
);
}
return style;
}