getTextSymbols method

List getTextSymbols()

Returns an array of SymbolRect, representing the current page. If the core is not initialised or the page is not ready, returns an empty array.

Implementation

List<SymbolRect> getTextSymbols() {
  List<SymbolRect> rects = [];

  Pointer<BufferArray>? symbolsArray = getTextSymbolsNative?.call(_sdk);

  if (symbolsArray != nullptr) {
    int arraySize = symbolsArray!.ref.count;
    Pointer<SymbolRectCore> coreRects = symbolsArray.ref.data.cast();
    for (int i = 0; i < arraySize; i++) {
      Pointer<SymbolRectCore> nativeRect = coreRects.elementAt(i);
      SymbolRect symbolRect = SymbolRect(
        nativeRect.ref.left,
        nativeRect.ref.top,
        nativeRect.ref.right,
        nativeRect.ref.bottom,
        nativeRect.ref.codePoint,
      );
      rects.add(symbolRect);
    }

    // TODO cleanup
  }

  return rects;
}