decorationImage static method

DecorationImage? decorationImage(
  1. DataSource source,
  2. List<Object> key
)

Returns a DecorationImage from the specified map.

The DecorationImage.image is determined by interpreting the same key as per imageProvider. If that method returns null, then this returns null also. Otherwise, the return value is used as the provider and additional keys map to the identically-named properties of DecorationImage: onError (must be an event handler; the payload map is augmented by an exception key that contains the text serialization of the exception and a stackTrace key that contains the stack trace, also as a string), colorFilter (colorFilter), fit (enumValue of BoxFit), alignment (alignment, defaults to Alignment.center), centerSlice (rect), repeat (enumValue of ImageRepeat, defaults to ImageRepeat.noRepeat), matchTextDirection (boolean, defaults to false).

Implementation

static DecorationImage? decorationImage(DataSource source, List<Object> key) {
  final ImageProvider? provider = imageProvider(source, key);
  if (provider == null) {
    return null;
  }
  return DecorationImage(
    image: provider,
    onError: (Object exception, StackTrace? stackTrace) {
      final VoidCallback? handler = source.voidHandler([...key, 'onError'], { 'exception': exception.toString(), 'stackTrack': stackTrace.toString() });
      if (handler != null) {
        handler();
      }
    },
    colorFilter: colorFilter(source, [...key, 'colorFilter']),
    fit: enumValue<BoxFit>(BoxFit.values, source, [...key, 'fit']),
    alignment: alignment(source, [...key, 'alignment']) ?? Alignment.center,
    centerSlice: rect(source, [...key, 'centerSlice']),
    repeat: enumValue<ImageRepeat>(ImageRepeat.values, source, [...key, 'repeat']) ?? ImageRepeat.noRepeat,
    matchTextDirection: source.v<bool>([...key, 'matchTextDirection']) ?? false,
  );
}