How to Unmount/Destroy Flutter Engine on Web?

Hi everyone,

I’m currently integrating a Flutter module into an existing legacy Angular webapp and have been following the documentation for embedding Flutter on the web. Starting the flutter engine using _flutter.loader.load({...}) works well and is clearly documented.

However, I haven’t been able to find any guidance on how to destroy or unmount the Flutter engine once it’s been initialized. In native Android, for example, it’s possible to clean up the engine, but I’m not seeing an equivalent for Flutter Web.

My use case requires mounting and unmounting the Flutter module dynamically, depending on the route or component being shown in the Angular app. Without a way to destroy the engine, I’m concerned about memory leaks and unnecessary CPU usage if the engine stays alive in the background.

I’m especially concerned in scenarios where multiple different Flutter modules might be loaded during navigation: if each route potentially spins up a new Flutter engine instance without being able to destroy the previous one, this could quickly become a performance issue. I want to avoid having orphaned engines or duplicated resources piling up over time.

Does anyone know if there’s a way to properly tear down the Flutter engine on web?

Thanks in advance!