convertFromHString function Null safety winrt

String convertFromHString(
  1. Pointer<IntPtr> hstring
)

Takes a HSTRING (a WinRT String), and converts it to a Dart String.

Implementation

String convertFromHString(Pointer<IntPtr> hstring) {
  final stringLength = calloc<Uint32>();

  try {
    final stringPtr = WindowsGetStringRawBuffer(hstring.value, stringLength);
    final dartString = stringPtr.toDartString();

    return dartString;
  } finally {
    free(stringLength);
  }
}