Skip to content

Commit

Permalink
[data_detector] fix not working on macos x64
Browse files Browse the repository at this point in the history
  • Loading branch information
boyan01 committed Aug 16, 2024
1 parent 66a8ed5 commit 08c1ce4
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/data_detector/lib/data_detector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@ class TextCheckingResult {
binding.NSTextCheckingType get type => _inner.resultType;

TextRange get range {
final p = malloc.allocate<binding.NSRange>(sizeOf<binding.NSRange>());
_inner.getRange(p);
final msgSend = objc.msgSendPointer
.cast<
NativeFunction<
binding.NSRange Function(
Pointer<objc.ObjCObject>, Pointer<objc.ObjCSelector>)>>()
.asFunction<
binding.NSRange Function(
Pointer<objc.ObjCObject>, Pointer<objc.ObjCSelector>)>();
final property = objc.registerName("range");

// the generated _inner.getRange() not working on macos x64, call send manually
final range = msgSend(_inner.pointer, property);
final textRange =
TextRange(start: p.ref.location, end: p.ref.location + p.ref.length);
malloc.free(p);
TextRange(start: range.location, end: range.location + range.length);
return textRange;
}

Expand Down

0 comments on commit 08c1ce4

Please sign in to comment.