Skip to content

Commit

Permalink
don't use dart.library.js for conditional import
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan-duncan committed Feb 12, 2025
1 parent 4f151c2 commit 0a95bc7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
4 changes: 1 addition & 3 deletions lib/src/command/executor.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export '_executor.dart'
if (dart.library.io) '_executor_io.dart'
if (dart.library.js) '_executor_html.dart';
export '_executor_html.dart' if (dart.library.io) '_executor_io.dart';
4 changes: 1 addition & 3 deletions lib/src/formats/jpeg/jpeg_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import '../../util/image_exception.dart';
import '../../util/input_buffer.dart';
import '_component_data.dart';
import '_jpeg_huffman.dart';
import '_jpeg_quantize_html.dart' if (dart.library.io) '_jpeg_quantize_io.dart';
import 'jpeg_adobe.dart';
import 'jpeg_component.dart';
import 'jpeg_frame.dart';
import 'jpeg_info.dart';
import 'jpeg_jfif.dart';
import 'jpeg_marker.dart';
import 'jpeg_quantize_stub.dart'
if (dart.library.io) '_jpeg_quantize_io.dart'
if (dart.library.js) '_jpeg_quantize_html.dart';
import 'jpeg_scan.dart';

@internal
Expand Down
15 changes: 9 additions & 6 deletions lib/src/transform/resize.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import 'copy_resize.dart';

Image resize(Image src,
{int? width,
int? height,
bool? maintainAspect,
Color? backgroundColor,
Interpolation interpolation = Interpolation.nearest}) {
int? height,
bool? maintainAspect,
Color? backgroundColor,
Interpolation interpolation = Interpolation.nearest}) {
if (width == null && height == null) {
throw ImageException('Invalid size');
}
Expand Down Expand Up @@ -75,8 +75,11 @@ Image resize(Image src,
}

if ((width * height) > (src.width * src.height)) {
return copyResize(src, width: width, height: height,
maintainAspect: maintainAspect, backgroundColor: backgroundColor,
return copyResize(src,
width: width,
height: height,
maintainAspect: maintainAspect,
backgroundColor: backgroundColor,
interpolation: interpolation);
}

Expand Down
4 changes: 1 addition & 3 deletions lib/src/util/file_access.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export '_file_access.dart'
if (dart.library.io) '_file_access_io.dart'
if (dart.library.js) '_file_access_html.dart';
export '_file_access_html.dart' if (dart.library.io) '_file_access_io.dart';
12 changes: 4 additions & 8 deletions test/transform/resize_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ void main() {
test('resize average', () {
final img =
decodePng(File('test/_data/png/buck_24.png').readAsBytesSync())!;
final i0 =
resize(img, width: 64, interpolation: Interpolation.average);
final i0 = resize(img, width: 64, interpolation: Interpolation.average);
expect(i0.width, equals(64));
expect(i0.height, equals(40));
File('$testOutputPath/transform/resize_average.png')
Expand All @@ -32,8 +31,7 @@ void main() {
test('resize linear', () {
final img =
decodePng(File('test/_data/png/buck_24.png').readAsBytesSync())!;
final i0 =
resize(img, width: 64, interpolation: Interpolation.linear);
final i0 = resize(img, width: 64, interpolation: Interpolation.linear);
expect(i0.width, equals(64));
expect(i0.height, equals(40));
File('$testOutputPath/transform/resize_linear.png')
Expand Down Expand Up @@ -168,10 +166,8 @@ void main() {

test('resize palette', () async {
final img = await decodePngFile('test/_data/png/test.png');
final i0 =
resize(img!, width: 64, interpolation: Interpolation.cubic);
await encodePngFile(
'$testOutputPath/transform/resize_palette.png', i0);
final i0 = resize(img!, width: 64, interpolation: Interpolation.cubic);
await encodePngFile('$testOutputPath/transform/resize_palette.png', i0);
});
});
}

0 comments on commit 0a95bc7

Please sign in to comment.