xvrh / lottie-flutter

Render After Effects animations natively on Flutter. This package is a pure Dart implementation of a Lottie player.
https://pub.dev/packages/lottie
MIT License
1.13k stars 197 forks source link

Can not clear memory when needed #80

Open ZoomZhao opened 4 years ago

ZoomZhao commented 4 years ago

There is LottieCache in lottie_provider.dart. can i clear the Cache after page disposed?

xvrh commented 4 years ago

Hi, This is a good feature request. There is still some work to do with cache management (pre-cache is on the list too).

As of now, you have to import a private file:

import 'package:lottie/src/providers/lottie_provider.dart' show sharedLottieCache;

main() {
  sharedLottieCache.clear();
}

This is a temporary hack that may not work in the future.

Otherwise, you can also not use Lottie.asset and Lottie.network and do the loading/caching yourself: See: https://github.com/xvrh/lottie-flutter/blob/master/example/lib/examples/custom_load.dart

Yongle-Fu commented 3 years ago
sharedLottieCache.clear();

i had try this, but Memory reduction is very limited, seems json or image not release.

Yongle-Fu commented 3 years ago
imageProvider?.evict()

seems work.

1xiaocainiao commented 3 years ago
imageProvider?.evict()

seems work.

lottie: ^0.7.0+1 not found imageProvider?.evict(), Which file should I refer to? Thank you.