Skip to content

Commit

Permalink
Throw more descriptive error when user has not included pica in their…
Browse files Browse the repository at this point in the history
… html (#302)

Co-authored-by: Caijinglong <cjl_spy@163.com>
  • Loading branch information
ShreyashKore and CaiJingLong authored Dec 4, 2024
1 parent 7f05c9b commit 32637ad
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/flutter_image_compress_web/lib/src/pica.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ Future<Uint8List> resizeWithList({
int quality = 88,
}) async {
final Stopwatch stopwatch = Stopwatch()..start();
final pica = window.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. '
'See documentation for more details https://github.com/fluttercandies/flutter_image_compress?tab=readme-ov-file#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 32637ad

Please sign in to comment.