styleFrom static method
ButtonStyle
styleFrom({
- Color? primary,
- Color? onSurface,
- Color? backgroundColor,
- 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? fail,
- Color? disable,
like ElevatedButton.styleFrom with state color for background success
, fail
Implementation
static ButtonStyle styleFrom({
Color? primary,
Color? onSurface,
Color? backgroundColor,
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? fail,
Color? disable,
}) {
final style = TextButton.styleFrom(
primary: primary,
onSurface: onSurface,
shadowColor: shadowColor,
backgroundColor: backgroundColor,
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 _StateTextForeground? foregroundColor =
(onSurface == null && fail == null && success == null)
? null
: _StateTextForeground(
primary: primary,
onSurface: onSurface,
onFail: fail,
onSuccess: success,
onDisable: disable,
);
return style.copyWith(
foregroundColor: foregroundColor,
);
}