encodeBoxDecoration static method

Map<String, dynamic>? encodeBoxDecoration(
  1. BoxDecoration? value
)

Encodes the given value into a JSON compatible map. This produces a Map in the following format:

{
  "backgroundBlendMode": "<BlendMode>",
  "border": "<BoxBorder>",
  "borderRadius": "<BorderRadius>",
  "boxShadow": "<BoxShadow[]>"
  "color": "<Color>",
  "image": "<DecorationImage>",
  "gradient": "<Gradient>",
  "shape": "<BoxShape>"
}

A value of null will result in null being returned.

See also:

Implementation

static Map<String, dynamic>? encodeBoxDecoration(BoxDecoration? value) {
  Map<String, dynamic>? result;

  if (value != null) {
    result = {
      'backgroundBlendMode': encodeBlendMode(value.backgroundBlendMode),
      'border': encodeBoxBorder(value.border as Border?),
      'borderRadius': encodeBorderRadius(value.borderRadius as BorderRadius?),
      'boxShadow': _encodeList(
        value.boxShadow,
        (value) => encodeBoxShadow(value),
      ),
      'color': encodeColor(value.color),
      'image': encodeDecorationImage(value.image),
      'gradient': encodeGradient(value.gradient),
      'shape': encodeBoxShape(value.shape),
    };
  }

  return _stripDynamicNull(result);
}