💄 Optimized image loading and error

This commit is contained in:
LittleSheep 2025-06-08 20:31:32 +08:00
parent 37f5c61905
commit d165e488ad
2 changed files with 11 additions and 1 deletions

View File

@ -119,7 +119,7 @@ class ProfilePictureWidget extends ConsumerWidget {
fallbackColor ??
Theme.of(context).colorScheme.onPrimaryContainer,
).center()
: CachedNetworkImage(imageUrl: uri, fit: BoxFit.cover),
: UniversalImage(uri: uri, fit: BoxFit.cover),
),
);
}

View File

@ -45,6 +45,16 @@ class UniversalImage extends StatelessWidget {
height: height,
memCacheHeight: cacheHeight,
memCacheWidth: cacheWidth,
progressIndicatorBuilder: (context, url, progress) {
return Center(
child: CircularProgressIndicator(value: progress.progress),
);
},
errorWidget: (context, url, error) {
return const Center(
child: Icon(Icons.broken_image, color: Colors.white, size: 16),
);
},
),
],
),