Skip to content

Commit

Permalink
Fix compatibility issues with archive 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan-duncan committed Dec 19, 2024
1 parent 4bc9563 commit 5a8c2a7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/src/font/bitmap_font.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:xml/xml.dart';

import '../formats/png_decoder.dart';
import '../image/image.dart';
import '../util/_cast.dart';
import '../util/image_exception.dart';

/// Decode a [BitmapFont] from the contents of a zip file that stores the
Expand Down Expand Up @@ -205,7 +206,8 @@ class BitmapFont {
'$filename');
}

final image = PngDecoder().decode(imageFile.content);
final image = PngDecoder()
.decode(castToUint8List(imageFile.content));

fontPages[id] = image;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/src/image/icc_profile.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:typed_data';
import 'package:archive/archive.dart';
import '../util/_cast.dart';

enum IccProfileCompression { none, deflate }

Expand Down Expand Up @@ -35,7 +36,7 @@ class IccProfile {
if (compression == IccProfileCompression.none) {
return data;
}
data = const ZLibDecoder().decodeBytes(data);
data = castToUint8List(const ZLibDecoder().decodeBytes(data));
compression = IccProfileCompression.none;
return data;
}
Expand Down
4 changes: 4 additions & 0 deletions lib/src/util/_cast.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import 'dart:typed_data';

Uint8List castToUint8List<T>(T data) =>
data is Uint8List ? data : data as Uint8List;

0 comments on commit 5a8c2a7

Please sign in to comment.