Skip to content

Commit

Permalink
Merge pull request NO-ob#232 from NO-ob/fixNetworkImage
Browse files Browse the repository at this point in the history
fix custom_network_image, dump beps
  • Loading branch information
NO-ob authored Nov 18, 2023
2 parents 56ae831 + ed06d7c commit cb2c127
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 36 deletions.
5 changes: 1 addition & 4 deletions lib/src/widgets/image/abstract_custom_network_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,5 @@ abstract class CustomNetworkImage extends ImageProvider<CustomNetworkImage> {
Map<String, String>? get headers;

@override
ImageStreamCompleter load(CustomNetworkImage key, DecoderCallback decode);

@override
ImageStreamCompleter loadBuffer(CustomNetworkImage key, DecoderBufferCallback decode);
ImageStreamCompleter loadImage(CustomNetworkImage key, ImageDecoderCallback decode);
}
32 changes: 5 additions & 27 deletions lib/src/widgets/image/custom_network_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,11 @@ class CustomNetworkImage extends ImageProvider<custom_network_image.CustomNetwor
}

@override
ImageStreamCompleter load(custom_network_image.CustomNetworkImage key, DecoderCallback decode) {
ImageStreamCompleter loadImage(custom_network_image.CustomNetworkImage key, ImageDecoderCallback decode) {
final StreamController<ImageChunkEvent> chunkEvents = StreamController<ImageChunkEvent>();

return MultiFrameImageStreamCompleter(
codec: _loadAsync(key as CustomNetworkImage, chunkEvents, null, decode),
chunkEvents: chunkEvents.stream,
scale: key.scale,
debugLabel: key.url,
informationCollector: () => <DiagnosticsNode>[
DiagnosticsProperty<ImageProvider>('Image provider', this),
DiagnosticsProperty<custom_network_image.CustomNetworkImage>('Image key', key),
],
);
}

@override
ImageStreamCompleter loadBuffer(custom_network_image.CustomNetworkImage key, DecoderBufferCallback decode) {
final StreamController<ImageChunkEvent> chunkEvents = StreamController<ImageChunkEvent>();

return MultiFrameImageStreamCompleter(
codec: _loadAsync(key as CustomNetworkImage, chunkEvents, decode, null),
codec: _loadAsync(key as CustomNetworkImage, chunkEvents, decode),
chunkEvents: chunkEvents.stream,
scale: key.scale,
debugLabel: key.url,
Expand Down Expand Up @@ -125,8 +109,7 @@ class CustomNetworkImage extends ImageProvider<custom_network_image.CustomNetwor
Future<ui.Codec> _loadAsync(
CustomNetworkImage key,
StreamController<ImageChunkEvent> chunkEvents,
DecoderBufferCallback? decode,
DecoderCallback? decodeDepreacted,
ImageDecoderCallback decode,
) async {
final Uri resolved = Uri.base.resolve(key.url);
final String cacheFilePath = await ImageWriter().getCachePathString(
Expand Down Expand Up @@ -236,13 +219,8 @@ class CustomNetworkImage extends ImageProvider<custom_network_image.CustomNetwor
throw Exception('CustomNetworkImage is an empty file: $resolved');
}

if (decode != null) {
final ui.ImmutableBuffer buffer = await ui.ImmutableBuffer.fromUint8List(bytes);
return decode(buffer);
} else {
assert(decodeDepreacted != null, 'decodeDepreacted must not be null');
return decodeDepreacted!(bytes);
}
final ui.ImmutableBuffer buffer = await ui.ImmutableBuffer.fromUint8List(bytes);
return decode(buffer);
} catch (e) {
if (onError != null) {
onError?.call(e);
Expand Down
10 changes: 5 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies:
alice_lightweight: ^3.4.0
app_links: ^3.4.3
auto_size_text: ^3.0.0
awesome_notifications: 0.7.4+1
awesome_notifications: ^0.8.2
chewie: ^1.5.0
crypto: ^3.0.2
cupertino_icons: ^1.0.5
Expand Down Expand Up @@ -55,18 +55,18 @@ dependencies:
flutter_linkify: ^6.0.0
font_awesome_flutter: ^10.5.0
get: ^4.6.5
google_fonts: ^4.0.4
google_fonts: ^6.1.0
html: ^0.15.4
huge_listview: ^2.0.11
image: ^4.0.15
intl: ^0.17.0
intl: ^0.18.1
keyboard_actions: ^4.2.0
logger_fork: ^1.2.0
logger_flutter_fork: ^1.3.1
# local_auth: ^2.1.0
# marquee: ^2.2.2 # replaced with fast_marquee
path_provider: ^2.1.0
permission_handler: ^10.4.3
permission_handler: ^11.0.1
photo_view: # ^0.12.0
git:
url: "https://github.com/NANI-SORE/photo_view.git"
Expand All @@ -78,7 +78,7 @@ dependencies:
sqflite: ^2.3.0
statsfl: ^2.3.0
transparent_image: ^2.0.1
uuid: ^3.0.7
uuid: ^4.2.1
vibration: ^1.7.5
video_player: ^2.7.0
waterfall_flow: ^3.0.2
Expand Down

0 comments on commit cb2c127

Please sign in to comment.