|
|
@@ -4,6 +4,7 @@ import 'package:flutter/foundation.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
+import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
|
|
import 'package:network_image_cached/src/http_request.dart';
|
|
|
|
|
|
import 'bloc/cashed_image_bloc.dart'
|
|
|
@@ -171,8 +172,31 @@ class CachedNetworkImageProvider
|
|
|
httpHeaders: httpHeaders,
|
|
|
);
|
|
|
// 2. Декодируем байты в ui.Image
|
|
|
+ DefaultCacheManager defaultCacheManager = DefaultCacheManager();
|
|
|
+ if (cached) {
|
|
|
+ FileInfo? fileInfo;
|
|
|
+ if (cacheKey != null) {
|
|
|
+ fileInfo = await defaultCacheManager.getFileFromCache(cacheKey!);
|
|
|
+ } else {
|
|
|
+ fileInfo = await defaultCacheManager.getFileFromCache(imageUrl);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (fileInfo != null) {}
|
|
|
+ }
|
|
|
+ Uint8List img;
|
|
|
+ try {
|
|
|
+ img = await httpGetImage.getDataObjectIsolate();
|
|
|
+ if (cached) {
|
|
|
+ if (cacheKey != null) {
|
|
|
+ defaultCacheManager.putFile(cacheKey!, img);
|
|
|
+ } else {
|
|
|
+ defaultCacheManager.putFile(imageUrl, img);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ throw Exception('Failed to load image: $e');
|
|
|
+ }
|
|
|
|
|
|
- Uint8List img = await httpGetImage.getDataObjectIsolate();
|
|
|
final decodedImage = await decode(
|
|
|
await ImmutableBuffer.fromUint8List(img),
|
|
|
);
|