HString.fromString constructor
HString.fromString(
- String string
Create a HString from a given Dart string
.
Implementation
factory HString.fromString(String string) {
if (string.isEmpty) return const HString.empty();
return using((arena) {
final pSourceString = string.toNativeUtf16(allocator: arena);
final pString = arena<HSTRING>();
final hr = WindowsCreateString(pSourceString, string.length, pString);
if (FAILED(hr)) throwWindowsException(hr);
return HString._(pString.value);
});
}