Skip to content

Commit 08c1ce4

Browse files
committed
[data_detector] fix not working on macos x64
1 parent 66a8ed5 commit 08c1ce4

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/data_detector/lib/data_detector.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,20 @@ class TextCheckingResult {
2626
binding.NSTextCheckingType get type => _inner.resultType;
2727

2828
TextRange get range {
29-
final p = malloc.allocate<binding.NSRange>(sizeOf<binding.NSRange>());
30-
_inner.getRange(p);
29+
final msgSend = objc.msgSendPointer
30+
.cast<
31+
NativeFunction<
32+
binding.NSRange Function(
33+
Pointer<objc.ObjCObject>, Pointer<objc.ObjCSelector>)>>()
34+
.asFunction<
35+
binding.NSRange Function(
36+
Pointer<objc.ObjCObject>, Pointer<objc.ObjCSelector>)>();
37+
final property = objc.registerName("range");
38+
39+
// the generated _inner.getRange() not working on macos x64, call send manually
40+
final range = msgSend(_inner.pointer, property);
3141
final textRange =
32-
TextRange(start: p.ref.location, end: p.ref.location + p.ref.length);
33-
malloc.free(p);
42+
TextRange(start: range.location, end: range.location + range.length);
3443
return textRange;
3544
}
3645

0 commit comments

Comments
 (0)