Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I clear Flutter's image cache?

Tags:

flutter

dart

Flutter has its own internal cache of images. I need to clear that image cache. How do I do that?

like image 550
Seth Ladd Avatar asked Nov 09 '17 19:11

Seth Ladd


People also ask

What is cache image?

An image service cache represents a snapshot of your image service at one point in time, with one or three bands, and using a specific mosaic method.


1 Answers

Refer to the Flutter docs

/// This is the custom implementation of [ImageCache] where we can override /// the logic. class MyImageCache extends ImageCache {   @override   void clear() {     print('Clearing cache!');     super.clear();   } }  class MyWidgetsBinding extends WidgetsFlutterBinding {   @override   ImageCache createImageCache() => MyImageCache(); }  void main() {   // The constructor sets global variables.   MyWidgetsBinding();   runApp(const MyApp()); }  class MyApp extends StatelessWidget {   const MyApp({Key? key}) : super(key: key);    @override   Widget build(BuildContext context) {     return Container();   } } 
like image 68
Arnold Parge Avatar answered Sep 26 '22 06:09

Arnold Parge