Skip to content

Commit 30c2de0

Browse files
author
huizzzhou
committed
fix: add interface class key for callback map
1 parent c1d11fa commit 30c2de0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

dart_native/lib/src/android/runtime/jobject.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,20 @@ class JObject extends Class {
1919

2020
//init target class
2121
JObject(String className, {Pointer pointer, bool isInterface = false}) : super(className) {
22-
_ptr = pointer;
23-
if (_ptr == null && !isInterface) {
22+
if (isInterface) {
23+
Pointer<Int64> hashPointer = allocate();
24+
hashPointer.value = identityHashCode(this);
25+
_ptr = hashPointer.cast<Void>();
26+
return;
27+
}
28+
29+
if (pointer == null) {
2430
Pointer<Utf8> classNamePtr = Utf8.toUtf8(super.className);
25-
_ptr = nativeCreateClass(classNamePtr, nullptr, nullptr);
31+
pointer = nativeCreateClass(classNamePtr, nullptr, nullptr);
2632
free(classNamePtr);
2733
}
34+
35+
_ptr = pointer;
2836
passJObjectToNative(this);
2937
}
3038

0 commit comments

Comments
 (0)