1- import 'package:cached_network_image/cached_network_image.dart' ;
21import 'package:codelessly_api/codelessly_api.dart' ;
32import 'package:flutter/foundation.dart' ;
43import 'package:flutter/material.dart' ;
@@ -20,8 +19,7 @@ class UltimateImageBuilder extends StatefulWidget {
2019 final ImageRepeat ? repeat;
2120 final Color ? color;
2221 final WidgetBuilder ? errorBuilder;
23- final Widget Function (BuildContext context, DownloadProgress ? progress)?
24- loadingBuilder;
22+ final Widget Function (BuildContext context, Widget ? child)? loadingBuilder;
2523 final PaintModel ? paint;
2624 final BaseNode ? node;
2725 final BlendMode ? blendMode;
@@ -68,8 +66,8 @@ class UltimateImageBuilder extends StatefulWidget {
6866 properties.add (
6967 ObjectFlagProperty <WidgetBuilder >.has ('errorBuilder' , errorBuilder));
7068 properties.add (ObjectFlagProperty <
71- Widget Function (BuildContext context,
72- DownloadProgress ? progress)>. has ( 'loadingBuilder' , loadingBuilder));
69+ Widget Function (BuildContext context, Widget ? child)>. has (
70+ 'loadingBuilder' , loadingBuilder));
7371 properties.add (DiagnosticsProperty <PaintModel >('paint' , paint));
7472 properties.add (DiagnosticsProperty <BaseNode >('node' , node));
7573 properties.add (EnumProperty <BlendMode >('blendMode' , blendMode));
@@ -210,8 +208,10 @@ class _UltimateImageBuilderState extends State<UltimateImageBuilder> {
210208
211209 if (url.containsUncheckedVariablePath) return jsonPathBuilder (url);
212210
211+ Widget child;
212+
213213 if (url.isSvgUrl) {
214- return SvgPicture .network (
214+ child = SvgPicture .network (
215215 url,
216216 fit: fit,
217217 alignment: alignment,
@@ -225,7 +225,7 @@ class _UltimateImageBuilderState extends State<UltimateImageBuilder> {
225225 }
226226
227227 if (url.isBase64Blob) {
228- return Image .memory (
228+ child = Image .memory (
229229 url.base64Data,
230230 fit: fit,
231231 alignment: alignment,
@@ -240,48 +240,35 @@ class _UltimateImageBuilderState extends State<UltimateImageBuilder> {
240240 );
241241 }
242242
243- return CachedNetworkImage (
244- imageUrl : url,
243+ child = Image . network (
244+ url,
245245 fit: fit,
246246 alignment: alignment,
247247 width: width,
248248 height: height,
249249 repeat: repeat,
250250 color: widget.color,
251+ opacity: AlwaysStoppedAnimation (widget.paint? .opacity ?? 1 ),
251252 filterQuality: FilterQuality .medium,
252- fadeInDuration: const Duration (milliseconds: 300 ),
253- fadeOutDuration: const Duration (milliseconds: 300 ),
254253 colorBlendMode: colorBlendMode,
255- placeholder: widget.loadingBuilder != null
256- ? (context, _) => widget.loadingBuilder !(context, null )
254+ loadingBuilder: widget.loadingBuilder != null
255+ ? (context, child, loadingProgress) =>
256+ widget.loadingBuilder !(context, child)
257257 : null ,
258- errorWidget: (context, _, __) =>
259- (widget.errorBuilder ?? _defaultErrorBuilder)(context),
260- imageBuilder: (context, imageProvider) {
261- return decorateImageProvider (imageProvider);
258+ errorBuilder: (context, error, stackTrace) {
259+ print ('Image Loading Error:' + error.toString ());
260+ return (widget.errorBuilder ?? _defaultErrorBuilder)(context);
262261 },
263262 );
264- }
265263
266- Widget decorateImageProvider (ImageProvider imageProvider) {
267- final decoration = BoxDecoration (
264+ final BoxDecoration decoration = BoxDecoration (
268265 borderRadius: widget.node is CornerMixin
269266 ? (widget.node as CornerMixin ).cornerRadius.borderRadius
270267 : null ,
271- image: DecorationImage (
272- image: imageProvider,
273- fit: fit,
274- repeat: repeat,
275- alignment: alignment,
276- opacity: widget.paint? .opacity ?? 1 ,
277- scale: scale,
278- colorFilter: colorFilter,
279- filterQuality: FilterQuality .medium,
280- ),
281268 );
282- Widget child = switch (widget.useInk) {
283- true => Ink (decoration: decoration),
284- false => DecoratedBox (decoration: decoration),
269+ child = switch (widget.useInk) {
270+ true => Ink (decoration: decoration, child : child ),
271+ false => DecoratedBox (decoration: decoration, child : child ),
285272 };
286273
287274 if (widget.paint? .hasFlippedAxis ?? false ) {
@@ -291,6 +278,7 @@ class _UltimateImageBuilderState extends State<UltimateImageBuilder> {
291278 child: child,
292279 );
293280 }
281+
294282 return child;
295283 }
296284
0 commit comments