rejectVectorDrawableSource function
Rejects vector-drawable (.xml) sources for adaptive foreground / monochrome
with a clear, actionable error. The image pipeline cannot rasterize XML
drawables; the previous behavior was an opaque getter 'width' was called on null deep inside the image package.
Implementation
void rejectVectorDrawableSource({
required String field,
required String value,
}) {
if (value.toLowerCase().endsWith('.xml')) {
throw InvalidConfigException(
"$field: '$value' — vector drawable (.xml) sources are not supported. "
'Supply a PNG, or open an issue if you need vector support.',
);
}
// adaptive_icon_foreground / _monochrome must be an image path. A hex
// literal would later be opened as a file and crash with `FileSystemException:
// Cannot open file, path = '#FFFFFF'` (upstream #175).
if (isHexColorLiteral(value)) {
throw InvalidConfigException(
"$field: '$value' must be an image path; hex color literals are not "
'valid here.',
);
}
}