code cleaning
This commit is contained in:
parent
b90c8df053
commit
5b166b9d97
|
|
@ -39,22 +39,11 @@ class _SkeletonImageState extends State<SkeletonImage> {
|
|||
|
||||
Future<void> _getImage() async {
|
||||
final url = RequestHelper.baseUrl + widget.imageUrl;
|
||||
|
||||
// final storage = StorageService.webStorage;
|
||||
// String? imageCache = storage['image-cache'];
|
||||
// final Map data = imageCache == null ? {} : jsonDecode(imageCache);
|
||||
// if (data.containsKey(url)) {
|
||||
// _bytes = Uint8List.fromList(
|
||||
// List<int>.from(data[url]),
|
||||
// );
|
||||
// } else {
|
||||
_bytes = (await http.get(
|
||||
Uri.parse(url),
|
||||
headers: {'Authorization': 'Bearer ${RequestService.token}'},
|
||||
))
|
||||
.bodyBytes;
|
||||
// addImageToStorage();
|
||||
// }
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
|
|
@ -62,27 +51,20 @@ class _SkeletonImageState extends State<SkeletonImage> {
|
|||
}
|
||||
}
|
||||
|
||||
// void addImageToStorage() {
|
||||
// final storage = StorageService.webStorage;
|
||||
// String? imageCache = storage['image-cache'];
|
||||
// final Map data = imageCache == null ? {} : Map.from(jsonDecode(imageCache));
|
||||
// data.addAll({RequestHelper.baseUrl + widget.imageUrl: _bytes});
|
||||
// StorageService.webStorage.addAll({'image-cache': jsonEncode(data)});
|
||||
// }
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return _aspectRatioGenerator(
|
||||
child: Builder(builder: (context) {
|
||||
if (kIsWeb) {
|
||||
if (_isLoading) {
|
||||
return ShimmerPlaceholder(
|
||||
return _aspectRatioGenerator(
|
||||
child: ShimmerPlaceholder(
|
||||
borderRadius: widget.borderRadius,
|
||||
width: widget.aspectRatio == null ? widget.width : null,
|
||||
height: widget.aspectRatio == null ? widget.height : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
return ClipRRect(
|
||||
return _aspectRatioGenerator(
|
||||
child: ClipRRect(
|
||||
borderRadius: widget.borderRadius,
|
||||
child: Image.memory(
|
||||
_bytes,
|
||||
|
|
@ -90,27 +72,11 @@ class _SkeletonImageState extends State<SkeletonImage> {
|
|||
width: widget.width,
|
||||
height: widget.height,
|
||||
),
|
||||
),
|
||||
);
|
||||
// Builder(
|
||||
// builder: (context) {
|
||||
// if (_bytes == null || _bytes!.isEmpty) {
|
||||
// return ShimmerPlaceholder(
|
||||
// borderRadius: widget.borderRadius,
|
||||
// );
|
||||
// }
|
||||
// return ClipRRect(
|
||||
// borderRadius: widget.borderRadius,
|
||||
// child: Image.memory(
|
||||
// _bytes!,
|
||||
// width: widget.width,
|
||||
// height: widget.height,
|
||||
// fit: BoxFit.cover,
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
}
|
||||
return CachedNetworkImage(
|
||||
return _aspectRatioGenerator(
|
||||
child: CachedNetworkImage(
|
||||
httpHeaders: {'Authorization': 'Bearer ${RequestService.token}'},
|
||||
width: widget.width,
|
||||
height: widget.height,
|
||||
|
|
@ -128,8 +94,7 @@ class _SkeletonImageState extends State<SkeletonImage> {
|
|||
ShimmerPlaceholder(
|
||||
borderRadius: widget.borderRadius,
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue