bloomPicture function
BloomNode
bloomPicture({
- required List<
PictureSource> sources, - required String fallbackSrc,
- String? alt,
- bool decorative = false,
- int? width,
- int? height,
- String? aspectRatio,
- List<
int> ? fallbackWidths, - String? sizes,
- ImageUrlBuilder? urlBuilder,
- ImageLoading loading = ImageLoading.lazy,
- ImageDecoding decoding = ImageDecoding.async,
- FetchPriority? fetchPriority,
- bool priority = false,
- String? placeholder,
- String? fallbackOnErrorSrc,
- ImageFit? fit,
- String? className,
- String? style,
- Map<
String, String> ? attrs, - BloomEventHandler? onClick,
- BloomEventHandler? onLoad,
- BloomEventHandler? onError,
- Ref<
Object> ? ref,
Art-directed, multi-format <picture> element descriptor helper.
Encloses one or more PictureSource elements (e.g. AVIF, WebP, breakpoint variants) followed by an accessible fallback bloomImage descriptor.
Multi-Format Negotiation & Art Direction
Browsers evaluate <source> children in top-to-bottom order, selecting the first
matching format or media query, and apply dimensions and styling from the inner <img>.
This enables serving modern formats (AVIF, WebP) with automatic fallback to standard formats
(JPEG, PNG) on older browsers.
SSR and Browser Compatibility
In SSR (renderToHtml), outputs a <picture> tag enclosing all <source> elements
and the fallback <img>. In browser DOM (mount), builds the corresponding DOM hierarchy
and attaches event listeners to the inner HTMLImageElement.
bloomPicture(
sources: [
PictureSource(
src: '/images/hero.avif',
type: 'image/avif',
widths: [640, 1024, 1600],
),
PictureSource(
src: '/images/hero.webp',
type: 'image/webp',
widths: [640, 1024, 1600],
),
],
fallbackSrc: '/images/hero.jpg',
alt: 'Bloom Framework Dashboard',
width: 1200,
height: 600,
priority: true,
);
See also:
- BloomPicture, the picture element descriptor node.
- PictureSource, specification for individual
<source>tags. - bloomImage, responsive image helper used for the fallback
<img>.
Implementation
BloomNode bloomPicture({
required List<PictureSource> sources,
required String fallbackSrc,
String? alt,
bool decorative = false,
int? width,
int? height,
String? aspectRatio,
List<int>? fallbackWidths,
String? sizes,
ImageUrlBuilder? urlBuilder,
ImageLoading loading = ImageLoading.lazy,
ImageDecoding decoding = ImageDecoding.async,
FetchPriority? fetchPriority,
bool priority = false,
String? placeholder,
String? fallbackOnErrorSrc,
ImageFit? fit,
String? className,
String? style,
Map<String, String>? attrs,
BloomEventHandler? onClick,
BloomEventHandler? onLoad,
BloomEventHandler? onError,
Ref<Object>? ref,
}) {
return BloomPicture(
sources: sources,
fallbackSrc: fallbackSrc,
alt: alt,
decorative: decorative,
width: width,
height: height,
aspectRatio: aspectRatio,
fallbackWidths: fallbackWidths,
sizes: sizes,
urlBuilder: urlBuilder,
loading: loading,
decoding: decoding,
fetchPriority: fetchPriority,
priority: priority,
placeholder: placeholder,
fallbackOnErrorSrc: fallbackOnErrorSrc,
fit: fit,
className: className,
style: style,
attrs: attrs,
onClick: onClick,
onLoad: onLoad,
onError: onError,
ref: ref,
);
}