flutter-unity-view-widget
flutter-unity-view-widget copied to clipboard
Add support for onDettached onAttach UnityWidget
Add support for onDettached onAttach UnityWidget to help setup and dispose Unity without loading a new scene
Description
I use the attached boolean in the FlutterUnityWidgetController to know if it is the the corresponding Widget is attached. When a UnityWidget is build it handles calling onAttached and onDetached on the Widgets which changed attached state. The last controller added in UnityPlayerUtils.controllers will be the one to be displayed (which correspond to the last one built).
I needed to change lib/src/io/mobile_unity_widget_controller.dart MobileUnityWidgetController._() constructor because the stream was not initialized before the event was sent so it was not caught. Only Android is supported for now.
Type of Change
- [x] โจ New feature (non-breaking change which adds functionality)
- [ ] ๐ ๏ธ Bug fix (non-breaking change which fixes an issue)
- [ ] โ Breaking change (fix or feature that would cause existing functionality to change)
- [ ] ๐งน Code refactor
- [ ] โ Build configuration change
- [ ] ๐ Documentation
- [ ] ๐๏ธ Chore
This looks handy but I think we could rework the api to match the new stream api for next release https://github.com/juicycleff/flutter-unity-view-widget/pull/733
Yes I think this is a good idea I will rebase this on #733
I introduced a small merge conflict by merging the null-safe example.
It should only be the api_screen.dart
file, and you can just keep all your current changes.
So keep all the FlutterUnityController.
calls instead of the 'newer' _unityWidgetController?.
calls.
@RoyalCoder88 Even though you've approved this, don't merge this before #733 is done. It contains commits (and new bugs) from that branch.
@RoyalCoder88 Even though you've approved this, don't merge this before #733 is done. It contains commits (and new bugs) from that branch.
Okey just let me know when it's ready I will test it properly, thanks!