Skip to content

Commit

Permalink
fix: Throw more descriptive error when user has not included pica in …
Browse files Browse the repository at this point in the history
…their html.
  • Loading branch information
ShreyashKore committed May 11, 2024
1 parent 2aa67cb commit 4bbbf6f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/flutter_image_compress_web/lib/src/pica.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import 'package:flutter_image_compress_platform_interface/flutter_image_compress
import 'package:js/js.dart';
import 'package:js/js_util.dart';

import 'window.dart';
import 'log.dart' as logger;
import 'window.dart';

@JS('pica.resize')
external dynamic resize(
Expand Down Expand Up @@ -39,7 +39,11 @@ Future<Uint8List> resizeWithList({
int quality = 88,
}) async {
final Stopwatch stopwatch = Stopwatch()..start();
final pica = jsWindow.pica() as Pica;
final pica = jsWindow.pica() as Pica?;
if (pica == null) {
throw Exception(
'Pica not found. This plugin requires pica for image compression on the web.');
}
logger.jsLog('The pica instance', pica);
logger.jsLog('src image buffer', buffer);
logger.dartLog('src image buffer length: ${buffer.length}');
Expand Down

0 comments on commit 4bbbf6f

Please sign in to comment.