@@ -204,32 +204,39 @@ class AssetGenImageAnimation {
204
204
}
205
205
206
206
ImageAnimation ? _parseAnimation (AssetType asset) {
207
- final decoder = switch (asset.mime) {
208
- 'image/gif' => img.GifDecoder (),
209
- 'image/webp' => img.WebPDecoder (),
210
- _ => null ,
211
- };
212
-
213
- if (decoder == null ) {
214
- return null ;
215
- }
207
+ try {
208
+ final decoder = switch (asset.mime) {
209
+ 'image/gif' => img.GifDecoder (),
210
+ 'image/webp' => img.WebPDecoder (),
211
+ _ => null ,
212
+ };
213
+
214
+ if (decoder == null ) {
215
+ return null ;
216
+ }
216
217
217
- final file = File (asset.fullPath);
218
- final bytes = file.readAsBytesSync ();
219
- final image = decoder.decode (bytes);
218
+ final file = File (asset.fullPath);
219
+ final bytes = file.readAsBytesSync ();
220
+ final image = decoder.decode (bytes);
220
221
221
- if (image == null ) {
222
- return null ;
223
- }
222
+ if (image == null ) {
223
+ return null ;
224
+ }
224
225
225
- return ImageAnimation (
226
- frames: image.frames.length,
227
- duration: Duration (
228
- milliseconds: image.frames.fold (
229
- 0 ,
230
- (duration, frame) => duration + frame.frameDuration,
226
+ return ImageAnimation (
227
+ frames: image.frames.length,
228
+ duration: Duration (
229
+ milliseconds: image.frames.fold (
230
+ 0 ,
231
+ (duration, frame) => duration + frame.frameDuration,
232
+ ),
231
233
),
232
- ),
233
- );
234
+ );
235
+ } catch (e) {
236
+ stderr.writeln (
237
+ '[WARNING] Failed to parse \' ${asset .path }\' animation information: $e ' ,
238
+ );
239
+ }
240
+ return null ;
234
241
}
235
242
}
0 commit comments