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 WidgetStateProperty 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
- encodeWidgetStatePropertyBorderSide
- encodeWidgetStatePropertyColor
- encodeWidgetStatePropertyDouble
- encodeWidgetStatePropertyEdgeInsetsGeometry
- encodeWidgetStatePropertyMouseCursor
- encodeWidgetStatePropertyOutlinedBorder
- encodeWidgetStatePropertySize
- encodeWidgetStatePropertyTextStyle
- 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': encodeWidgetStatePropertyColor(
value.backgroundColor,
),
'elevation': encodeWidgetStatePropertyDouble(value.elevation),
'enableFeedback': value.enableFeedback,
'fixedSize': encodeWidgetStatePropertySize(value.fixedSize),
'foregroundColor': encodeWidgetStatePropertyColor(
value.foregroundColor,
),
'iconColor': encodeWidgetStatePropertyColor(value.iconColor),
'iconSize': encodeWidgetStatePropertyDouble(value.iconSize),
'maximumSize': encodeWidgetStatePropertySize(value.maximumSize),
'minimumSize': encodeWidgetStatePropertySize(value.minimumSize),
'mouseCursor': encodeWidgetStatePropertyMouseCursor(
value.mouseCursor,
),
'overlayColor': encodeWidgetStatePropertyColor(value.overlayColor),
'padding': encodeWidgetStatePropertyEdgeInsetsGeometry(value.padding),
'shadowColor': encodeWidgetStatePropertyColor(value.shadowColor),
'shape': encodeWidgetStatePropertyOutlinedBorder(value.shape),
'side': encodeWidgetStatePropertyBorderSide(value.side),
'splashFactory': encodeInteractiveInkFeatureFactory(
value.splashFactory,
),
'surfaceTintColor': encodeWidgetStatePropertyColor(
value.surfaceTintColor,
),
'tapTargetSize': encodeMaterialTapTargetSize(
value.tapTargetSize,
),
'textStyle': encodeWidgetStatePropertyTextStyle(value.textStyle),
'visualDensity': encodeVisualDensity(
value.visualDensity,
),
};
}
return _stripDynamicNull(result);
}