encodeButtonStyle static method
Encodes the given value
into a JSON representation.
{
"alignment": "<AlignmentGeometry>",
"animationDuration": "<MaterialStateProperty<double>>",
"backgroundColor": "<MaterialStateProperty<Color>>",
"elevation": "<MaterialStateProperty<double>>",
"enableFeedback": "<bool>",
"fixedSize": "<MaterialStateProperty<double>>",
"foregroundColor": "<MaterialStateProperty<Color>>",
"iconColor": "<MaterialStateProperty<Color>>",
"iconSize": "<MaterialStateProperty<double>>",
"maximumSize": "<MaterialStateProperty<double>>",
"minimumSize": "<MaterialStateProperty<Size>>",
"mouseCursor": "<MaterialStateProperty<MouseCursor>>",
"overlayColor": "<MaterialStateProperty<Color>>",
"padding": "<MaterialStateProperty<EdgeInsetsGeometry>>",
"shadowColor": "<MaterialStateProperty<Color>>",
"shape": "<MaterialStateProperty<OutlinedBorder>>",
"side": "<MaterialStateProperty<BorderSide>>",
"splashFactory": "<InteractiveInkSplashFactory>",
"surfaceTintColor": "<MaterialStateProperty<Color>>",
"tapTargetSize": "<MaterialTapTargetSize>",
"textStyle": "<MaterialStateProperty<TextStyle>>",
"visualDensity": "<VisualDensity>"
}
This won't maintain the MaterialStateProperty of each corresponding property, instead will resolve them by using an empty set of states, returning and encoding the resolved object.
See also:
- encodeBorderSide
- encodeColor
- encodeEdgeInsetsGeometry
encodeInteractiveInkSplashFactory
- encodeMaterialStatePropertyBorderSide
- encodeMaterialStatePropertyColor
- encodeMaterialStatePropertyDouble
- encodeMaterialStatePropertyEdgeInsetsGeometry
- encodeMaterialStatePropertyMouseCursor
- encodeMaterialStatePropertyOutlinedBorder
- encodeMaterialStatePropertySize
- encodeMaterialStatePropertyTextStyle
- encodeMaterialTapTargetSize
- encodeMouseCursor
- encodeOutlinedBorder
- encodeSize
- encodeTextStyle
- encodeVisualDensity
Implementation
static Map<String, dynamic>? encodeButtonStyle(
ButtonStyle? value,
) {
Map<String, dynamic>? result;
if (value != null) {
result = <String, dynamic>{
'alignment': encodeAlignmentGeometry(value.alignment),
'animationDuration': value.animationDuration?.inMilliseconds,
'backgroundColor': encodeMaterialStatePropertyColor(
value.backgroundColor,
),
'elevation': encodeMaterialStatePropertyDouble(value.elevation),
'enableFeedback': value.enableFeedback,
'fixedSize': encodeMaterialStatePropertySize(value.fixedSize),
'foregroundColor': encodeMaterialStatePropertyColor(
value.foregroundColor,
),
'iconColor': encodeMaterialStatePropertyColor(value.iconColor),
'iconSize': encodeMaterialStatePropertyDouble(value.iconSize),
'maximumSize': encodeMaterialStatePropertySize(value.maximumSize),
'minimumSize': encodeMaterialStatePropertySize(value.minimumSize),
'mouseCursor': encodeMaterialStatePropertyMouseCursor(
value.mouseCursor,
),
'overlayColor': encodeMaterialStatePropertyColor(value.overlayColor),
'padding': encodeMaterialStatePropertyEdgeInsetsGeometry(value.padding),
'shadowColor': encodeMaterialStatePropertyColor(value.shadowColor),
'shape': encodeMaterialStatePropertyOutlinedBorder(value.shape),
'side': encodeMaterialStatePropertyBorderSide(value.side),
'splashFactory': encodeInteractiveInkFeatureFactory(
value.splashFactory,
),
'surfaceTintColor': encodeMaterialStatePropertyColor(
value.surfaceTintColor,
),
'tapTargetSize': encodeMaterialTapTargetSize(
value.tapTargetSize,
),
'textStyle': encodeMaterialStatePropertyTextStyle(value.textStyle),
'visualDensity': encodeVisualDensity(
value.visualDensity,
),
};
}
return _stripNull(result);
}