boxShadow method

  1. @preferInline
List<BoxShadow>? boxShadow({
  1. String key = FlutterPropertyKeys.boxShadow,
  2. List<BoxShadow>? defaultValue,
  3. Object? target,
  4. bool warmUp = false,
})

Retrieves a list of BoxShadow values from the JSON map for the given key.

Looks up the value associated with key in the JSON. If the value is already a List<BoxShadow>, it is returned as is. If the value is a List, it attempts to parse it into a list of BoxShadow. Otherwise, it returns defaultValue.

  • key: The key to look up in the JSON map. Defaults to 'boxShadow'.
  • defaultValue: The value to return if the key is not found or cannot be resolved. Defaults to null.

Returns:

  • A list of BoxShadow if the value is valid or can be parsed.
  • defaultValue if the value is not a valid list of BoxShadow or cannot be parsed.
  • null if both the value and defaultValue are null.

Implementation

@preferInline
List<BoxShadow>? boxShadow({
  String key = FlutterPropertyKeys.boxShadow,
  List<BoxShadow>? defaultValue,
  Object? target,
  bool warmUp = false,
}) {
  final value = _readProp(key, target, warmUp);

  if (value is List<BoxShadow>) return value;

  if (value == null) return defaultValue;

  switch (value) {
    case List():
      if (envAttributeWarmUpEnabled) {
        if (warmUp) {
          return value.map<BoxShadow>(_boxShadowFromMap).toList();
        } else {
          return _json[key] =
              value.map<BoxShadow>(_boxShadowFromMap).toList();
        }
      } else {
        return _json[key] = value.map<BoxShadow>(_boxShadowFromMap).toList();
      }
    default:
      return defaultValue;
  }
}