Closed yudhishthir-siterecon closed 1 month ago
Hi! Unfortunately, cleanup is not properly supported in the current Flutter version. Flutter web team added proper support for cleanup in the new multi-view scenario, but this scenario is not fully stable yet (although the functionality is already available in the latest Flutter version 3.22).
I have a PR where this new scenario is used for react app: https://github.com/p-mazhnik/flutter-embedding/pull/10, and I listed there some remaining pieces from the Flutter that are required to land the PR. The changes are also deployed here: https://p-mazhnik.github.io/flutter-embedding/react-multiview/
If I understood correctly, you want something like this: https://github.com/p-mazhnik/flutter-embedding/blob/fbabd30d97af170ae727ce4df287580fc74d74c6/cra-flutter/src/App/FlutterView/FlutterView.tsx#L66-L72 https://github.com/p-mazhnik/flutter-embedding/pull/10/files#diff-ea063f4ae88d7bc3ee95cd1ee2d4991a80c23bd36f01e4691193635a8a1e1d97R71
To summarize, you can try to update your code as in the PR, and see if it solves your issues. But keep in mind that some functionality might be broken
I have successfully embedded a Flutter app in React (web) but I'm facing an issue of multiple instances of the flutter app.
When the wrapper (FlutterView) unmounts, I want the flutter app to be disposed. A new app is instantiated each time the wrapper React component re-mounts, while the previous instance remains. I need some function which I can call in the cleanup function of this react component, tried making _flutter null but that caused different set of issues.
Here's the current code, the main issue is I keep seeing logs even after the FlutterView is unmounted:
Hello from Flutter! Timer ticked at 2024-07-11 21:20:11.069
main.dart:
FlutterView.tsx: