styleFrom static method
ButtonStyle
styleFrom({
- Color? primary,
- Color? onPrimary,
- Color? onSurface,
- Color? shadowColor,
- 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? success,
- Color? onSuccess,
- Color? fail,
- Color? onFail,
- Color? disable,
- Color? onDisable,
like ElevatedButton.styleFrom with state color for background success
, fail
and state color for foreground onSuccess
, onFail
Implementation
static ButtonStyle styleFrom({
Color? primary,
Color? onPrimary,
Color? onSurface,
Color? shadowColor,
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,
//extend fields
Color? success,
Color? onSuccess,
Color? fail,
Color? onFail,
Color? disable,
Color? onDisable,
}) {
final style = ElevatedButton.styleFrom(
primary: primary,
onPrimary: onPrimary,
onSurface: onSurface,
shadowColor: shadowColor,
elevation: elevation,
textStyle: textStyle,
padding: padding,
minimumSize: minimumSize,
fixedSize: fixedSize,
maximumSize: maximumSize,
side: side,
shape: shape,
enabledMouseCursor: enabledMouseCursor,
disabledMouseCursor: disabledMouseCursor,
visualDensity: visualDensity,
tapTargetSize: tapTargetSize,
animationDuration: animationDuration,
enableFeedback: enableFeedback,
alignment: alignment,
splashFactory: splashFactory,
);
final _StateBackground? backgroundColor = (onSurface == null &&
primary == null &&
fail == null &&
success == null)
? null
: _StateBackground(
primary: primary,
onSurface: onSurface,
fail: fail,
success: success,
disable: disable,
);
final _StateForeground? foregroundColor = (onSurface == null &&
onPrimary == null &&
onFail == null &&
onSuccess == null)
? null
: _StateForeground(
onPrimary: onPrimary,
onSurface: onSurface,
onFail: onFail,
onSuccess: onSuccess,
onDisable: onDisable,
);
return style.copyWith(
backgroundColor: backgroundColor,
foregroundColor: foregroundColor,
);
}