styleFrom static method
- Color? foregroundColor,
- Color? backgroundColor,
- Color? disabledForegroundColor,
- Color? disabledBackgroundColor,
- Color? shadowColor,
- Color? surfaceTintColor,
- Color? iconColor,
- TextStyle? textStyle,
- Color? overlayColor,
- double? elevation,
- EdgeInsetsGeometry? padding,
- Size? minimumSize,
- Size? fixedSize,
- Size? maximumSize,
- MouseCursor? enabledMouseCursor,
- MouseCursor? disabledMouseCursor,
- BorderSide? side,
- OutlinedBorder? shape,
- VisualDensity? visualDensity,
- MaterialTapTargetSize? tapTargetSize,
- Duration? animationDuration,
- bool? enableFeedback,
- AlignmentGeometry? alignment,
- InteractiveInkFeatureFactory? splashFactory,
A static convenience method that constructs a SubmenuButton's ButtonStyle given simple values.
The foregroundColor
color is used to create a MaterialStateProperty
ButtonStyle.foregroundColor value. Specify a value for foregroundColor
to specify the color of the button's icons. Use backgroundColor
for the
button's background fill color. Use disabledForegroundColor
and
disabledBackgroundColor
to specify the button's disabled icon and fill
color.
All of the other parameters are either used directly or used to create a MaterialStateProperty with a single value for all states.
All parameters default to null, by default this method returns a ButtonStyle that doesn't override anything.
For example, to override the default foreground color for a SubmenuButton, as well as its overlay color, with all of the standard opacity adjustments for the pressed, focused, and hovered states, one could write:
SubmenuButton(
leadingIcon: const Icon(Icons.pets),
style: SubmenuButton.styleFrom(foregroundColor: Colors.green),
menuChildren: const <Widget>[ /* ... */ ],
child: const Text('Button Label'),
),
Implementation
static ButtonStyle styleFrom({
Color? foregroundColor,
Color? backgroundColor,
Color? disabledForegroundColor,
Color? disabledBackgroundColor,
Color? shadowColor,
Color? surfaceTintColor,
Color? iconColor,
TextStyle? textStyle,
Color? overlayColor,
double? elevation,
EdgeInsetsGeometry? padding,
Size? minimumSize,
Size? fixedSize,
Size? maximumSize,
MouseCursor? enabledMouseCursor,
MouseCursor? disabledMouseCursor,
BorderSide? side,
OutlinedBorder? shape,
VisualDensity? visualDensity,
MaterialTapTargetSize? tapTargetSize,
Duration? animationDuration,
bool? enableFeedback,
AlignmentGeometry? alignment,
InteractiveInkFeatureFactory? splashFactory,
}) {
return TextButton.styleFrom(
foregroundColor: foregroundColor,
backgroundColor: backgroundColor,
disabledBackgroundColor: disabledBackgroundColor,
disabledForegroundColor: disabledForegroundColor,
shadowColor: shadowColor,
surfaceTintColor: surfaceTintColor,
iconColor: iconColor,
textStyle: textStyle,
overlayColor: overlayColor,
elevation: elevation,
padding: padding,
minimumSize: minimumSize,
fixedSize: fixedSize,
maximumSize: maximumSize,
enabledMouseCursor: enabledMouseCursor,
disabledMouseCursor: disabledMouseCursor,
side: side,
shape: shape,
visualDensity: visualDensity,
tapTargetSize: tapTargetSize,
animationDuration: animationDuration,
enableFeedback: enableFeedback,
alignment: alignment,
splashFactory: splashFactory,
);
}