flutter-unity-view-widget icon indicating copy to clipboard operation
flutter-unity-view-widget copied to clipboard

How to structure the app to prevent duliplicated instances with router

Open proto-ziii opened this issue 1 year ago • 0 comments

Hi. I'm new to Flutter. And I wonder what is the recommended way to structure an app with the router and UnityWidget working simultaneously?

My goal is to have a single UnityWidget always fixed in the background, no matter how the router and overlay UI change. But currently, a new instance of UnityWidget will be created on router update and events such as onUnityMessage is duplicated.

I tried moving UnityWidget outside the router, but touch input on Unity won't work as it's also outside of the Scaffold.

Here is a simplified structure of my current app.

MaterialApp
└ Router
   └ Scaffold
      └ Stack
         ├ UnityWidget
         └ (other UI)

Thanks!

proto-ziii avatar Jun 03 '23 04:06 proto-ziii