imagePreviewImage function
Builds a preview image for imagePath, routed through UIImage so it
inherits the kit's caching, UIImageScope builders, and error handling.
Falls back to imagePreviewPlaceholder for empty paths and load failures. When the color overrides are omitted the placeholder resolves its palette from the ambient Theme.
Implementation
Widget imagePreviewImage(
String imagePath, {
required String fallbackTitle,
BoxFit fit = BoxFit.contain,
Color? gradientStart,
Color? gradientEnd,
Color? accentColor,
Color? iconColor,
}) {
final trimmed = imagePath.trim();
return Builder(
builder: (context) {
final placeholder = imagePreviewPlaceholder(
context,
fallbackTitle,
gradientStart: gradientStart,
gradientEnd: gradientEnd,
accentColor: accentColor,
iconColor: iconColor,
);
if (trimmed.isEmpty) return placeholder;
final isNetwork =
trimmed.startsWith('http://') || trimmed.startsWith('https://');
return UIImage(
trimmed,
isAsset: !isNetwork,
fit: fit,
width: double.infinity,
height: double.infinity,
alignment: Alignment.center,
placeholder: placeholder,
fallback: placeholder,
);
},
);
}