defaultStyleOf method
- BuildContext context
Defines the button's default appearance.
The button child's Text and Icon widgets are rendered with the ButtonStyle's foreground color. The button's InkWell adds the style's overlay color when the button is focused, hovered or pressed. The button's background color becomes its Material color and is transparent by default.
All of the ButtonStyle's defaults appear below.
In this list "Theme.foo" is shorthand for
Theme.of(context).foo
. Color scheme values like
"onSurface(0.38)" are shorthand for
onSurface.withOpacity(0.38)
. WidgetStateProperty valued
properties that are not followed by a sublist have the same
value for all states, otherwise the values are as specified for
each state and "others" means all other states.
The "default font size" below refers to the font size specified in the
defaultStyleOf method (or 14.0 if unspecified), scaled by the
MediaQuery.textScalerOf(context).scale
method. And the names of the
EdgeInsets constructors and EdgeInsetsGeometry.lerp
have been abbreviated
for readability.
The color of the ButtonStyle.textStyle is not used, the ButtonStyle.foregroundColor color is used instead.
textStyle
- Theme.textTheme.labelLargebackgroundColor
- transparentforegroundColor
- disabled - Theme.colorScheme.onSurface(0.38)
- others - Theme.colorScheme.primary
overlayColor
- hovered - Theme.colorScheme.primary(0.08)
- focused or pressed - Theme.colorScheme.primary(0.1)
- others - null
shadowColor
- Colors.transparent,surfaceTintColor
- nullelevation
- 0padding
default font size <= 14
- lerp(horizontal(12), horizontal(4))14 < default font size <= 28
- lerp(all(8), horizontal(8))28 < default font size <= 36
- lerp(horizontal(8), horizontal(4))36 < default font size
- horizontal(4)
minimumSize
- Size(64, 40)fixedSize
- nullmaximumSize
- Size.infiniteside
- nullshape
- StadiumBorder()mouseCursor
- disabled - SystemMouseCursors.basic
- others - SystemMouseCursors.click
visualDensity
- theme.visualDensitytapTargetSize
- theme.materialTapTargetSizeanimationDuration
- kThemeChangeDurationenableFeedback
- truealignment
- Alignment.centersplashFactory
- Theme.splashFactory
For the TextButton.icon factory, the end (generally the right) value of
padding
is increased from 12 to 16.
Implementation
ButtonStyle defaultStyleOf(BuildContext context) {
return _MenuButtonDefaultsM3(context);
}