Skip to content

Commit a27d444

Browse files
committed
formatting
1 parent 890d816 commit a27d444

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

flutter_cache_manager/lib/src/cache_managers/image_cache_manager.dart

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ mixin ImageCacheManager on BaseCacheManager {
2626
int? maxWidth,
2727
}) async* {
2828
if (maxHeight == null && maxWidth == null) {
29-
yield* getFileStream(url, key: key, headers: headers, withProgress: withProgress);
29+
yield* getFileStream(url,
30+
key: key, headers: headers, withProgress: withProgress);
3031
return;
3132
}
3233
key ??= url;
@@ -75,9 +76,12 @@ mixin ImageCacheManager on BaseCacheManager {
7576
}
7677

7778
var image = await _decodeImage(originalFile.file);
78-
79-
var shouldResize = maxWidth != null ? image.width > maxWidth : false ||
80-
maxHeight != null ? image.height > maxHeight : false;
79+
80+
var shouldResize = maxWidth != null
81+
? image.width > maxWidth
82+
: false || maxHeight != null
83+
? image.height > maxHeight
84+
: false;
8185
if (!shouldResize) return originalFile;
8286
if (maxWidth != null && maxHeight != null) {
8387
var resizeFactorWidth = image.width / maxWidth;
@@ -88,8 +92,12 @@ mixin ImageCacheManager on BaseCacheManager {
8892
maxHeight = (image.height / resizeFactor).round();
8993
}
9094

91-
var resized = await _decodeImage(originalFile.file, width: maxWidth, height: maxHeight, allowUpscaling: false);
92-
var resizedFile = (await resized.toByteData(format: ui.ImageByteFormat.png))!.buffer.asUint8List();
95+
var resized = await _decodeImage(originalFile.file,
96+
width: maxWidth, height: maxHeight, allowUpscaling: false);
97+
var resizedFile =
98+
(await resized.toByteData(format: ui.ImageByteFormat.png))!
99+
.buffer
100+
.asUint8List();
93101
var maxAge = originalFile.validTill.difference(DateTime.now());
94102

95103
var file = await putFile(

flutter_cache_manager/test/image_cache_manager_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const fileName = 'test.jpg';
1414
const fileUrl = 'baseflow.com/test';
1515
final validTill = DateTime.now().add(const Duration(days: 1));
1616
void main() {
17-
1817
setUp(() {
1918
WidgetsFlutterBinding.ensureInitialized();
2019
});
@@ -24,7 +23,6 @@ void main() {
2423
PaintingBinding.instance?.imageCache?.clearLiveImages();
2524
});
2625

27-
2826
group('Test image resizing', () {
2927
test('Test original image size', () async {
3028
final bytes = await getExampleImage();

0 commit comments

Comments
 (0)