Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 38ad9b3

Browse files
committedJan 9, 2023
Fix call order created init + detached on dispose
1 parent 6fe1e83 commit 38ad9b3

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed
 

‎lib/src/io/mobile_unity_widget_controller.dart

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ class MobileUnityWidgetController extends UnityWidgetController {
3636
unityWidgetState,
3737
unityId: id,
3838
);
39-
await UnityWidgetPlatform.instance.init(id);
40-
return controller;
4139
}
4240

4341
void _connectStreams(int unityId) {

‎lib/src/io/unity_widget.dart

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class _UnityWidgetState extends State<UnityWidget> {
155155

156156
@override
157157
Future<void> dispose() async {
158+
widget.onUnityDetached?.call();
158159
if (!kIsWeb) {
159160
if (_nextUnityCreationId > 0) --_nextUnityCreationId;
160161
}

‎lib/src/web/web_unity_widget_controller.dart

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class WebUnityWidgetController extends UnityWidgetController {
3535

3636
MethodChannel? _channel;
3737

38+
@override
39+
int get id => throw UnimplementedError("Platform does not support id");
40+
3841
/// used for cancel the subscription
3942
StreamSubscription? _onUnityMessageSub,
4043
_onUnitySceneLoadedSub,

0 commit comments

Comments
 (0)
Please sign in to comment.