Repository: flutter
Issue: [flutter_svg] No response from precachePicture when restart app
Labels: package,p: flutter_svg

_Imported from https://github.com/dnfield/flutter_svg/issues/677_

Original report by @Adrek on Mar 10, 2022

Hello everyone,
I will appreciate your help on how the precachePicture works.

I have a future function that waits for the preload of an SVG. It then performs another action like sending to a route containing the svg for example. But something happens that I can't understand.

```
Future<void> _preloadImages() async {
  await precachePicture(
      ExactAssetPicture(
          SvgPicture.svgStringDecoderBuilder, 'assets/icons/car_driving.svg'),
      context);

  // The first time, the next line is executed correctly.
  // But, when I press Restart app, the following line is not executed. The app is waiting for the future.
  print('Go to page that contains svg key');
}
```

- When the app is stopped, I start debugging with F5 in VSCode. The precachePicture function preloads the SVG and executes the next line that sends to another page and displays the widget with the svg. So far so good.

- With the application running, I press Restart in VSCode  ![dato](https://i.imgur.com/RFxJDqT.png), the precachePicture function is called and it stays there. I get no response from the future, so the next line is not executed. Why is this behavior? It only fixes itself if I stop the app and run it again.


I know that in the build release this would not be a problem because the user does not have an option to restart. However, in the development environment it is frustrating to be stopping the application and running again.

Thank you very much in advance

---
Comment by @dnfield on Mar 10, 2022
Hmm. Perhaps we need to clear the cache when `reassemble` is called.

---
Comment by @dnfield on Mar 13, 2022
I don't have a lot of time to do a test case for this - can yo do a small test that calls `PicturerProvider.cache.clear()` when reassemble is called? You can see an example of how to listen to reassemble in https://stackoverflow.com/questions/55281077/how-to-detect-hot-reload-inside-the-code-of-a-flutter-app

I'm relatively confident that that is the problem. If you can verify, there's an easy fix for it.

---
Comment by @Adrek on Mar 21, 2022
> I don't have a lot of time to do a test case for this - can yo do a small test that calls `PicturerProvider.cache.clear()` when reassemble is called? You can see an example of how to listen to reassemble in https://stackoverflow.com/questions/55281077/how-to-detect-hot-reload-inside-the-code-of-a-flutter-app
> 
> I'm relatively confident that that is the problem. If you can verify, there's an easy fix for it.

Thank you very much for answering.

I did it according to the link you sent but reassemble is called when it is hot reload but not in hot restart. 

For another way, I'm calling PicturerProvider.cache.clear() and it doesn't fix the problem when I do Hot restart. Is there another way to attack this issue? Thank you very much for your help.

---
Comment by @mekhribonu-s-codexoptimus on Jun 2, 2022
Cant catch exception or any response from precache. Is there any solution?