ui/widgets/custom_image
library
Functions
-
cachedNetworkProfileImage(String profileId, String mediaUrl)
→ Widget
-
-
cachedVideoThumbnail({required String thumbnailUrl, required String mediaUrl})
→ Widget
-
-
fileImage(File mediaFile)
→ Widget
-
-
platformCircleAvatar({required String imageUrl, double radius = 20, Color? backgroundColor, Widget? child})
→ Widget
-
Platform-aware circular avatar for network images.
On web: uses Image.network + ClipOval (Flutter-rendered, properly clippable).
On mobile: uses standard CircleAvatar with CachedNetworkImageProvider.
Use this instead of CircleAvatar(backgroundImage: platformImageProvider(...))
-
platformDecorationImage({required String imageUrl, BoxFit fit = BoxFit.cover, ColorFilter? colorFilter, BorderRadius? borderRadius, Color? color})
→ BoxDecoration?
-
Platform-aware BoxDecoration with network image.
On web: returns plain decoration (no image) since DecorationImage
paints on Canvas which requires CORS. Use a Stack with
platformNetworkImage instead for web backgrounds.
On mobile: returns BoxDecoration with DecorationImage.
-
platformImageProvider(String imageUrl, {int? maxHeight, int? maxWidth})
→ ImageProvider<Object>
-
Platform-aware image provider.
On web: returns NetworkImage (works for same-origin and CORS-enabled URLs
like Google, Firebase Storage, etc.). For cross-origin URLs without CORS,
use platformNetworkImage() or platformCircleAvatar() instead.
On mobile: returns CachedNetworkImageProvider for disk caching.
NOTE: Do NOT use webHtmlElementStrategy: prefer — it loads via HTML
but then fails with EncodingError when extracting pixels for Canvas painting.
-
platformNetworkImage({required String imageUrl, Key? key, BoxFit fit = BoxFit.cover, double? height, double? width, Widget? placeholder, Widget? errorWidget})
→ Widget
-
Platform-aware network image widget.
On web: uses native HTML
via HtmlElementView to bypass CanvasKit CORS.
On mobile: uses CachedNetworkImage for disk caching + better UX.