takeString method
String
takeString(
- SodiumPointer<
Char> pointer, { - bool zeroTerminated = true,
- Encoding encoding = utf8,
Copies pointer out as a Dart String, then frees the native buffer
immediately and stops tracking it.
Freeing at once (rather than deferring to scope exit) ensures secret hash
strings are zeroed as soon as possible. zeroTerminated stops decoding at
the first NUL byte; encoding selects the encoding and defaults to
utf8. Wraps CharSodiumPtr.toDartString. pointer must be
a pointer this scope owns.
If the decoding fails, pointer stays tracked so the scope still frees
it.
Implementation
String takeString(
SodiumPointer<Char> pointer, {
bool zeroTerminated = true,
Encoding encoding = utf8,
}) {
final result = pointer.toDartString(
zeroTerminated: zeroTerminated,
encoding: encoding,
);
_untrack(pointer);
pointer.dispose();
return result;
}