withUtf8<T> function
Run fn with a temporary native UTF-8 copy of s; always frees it.
Implementation
T withUtf8<T>(String s, T Function(Pointer<Utf8>) fn) {
final ptr = s.toNativeUtf8();
try {
return fn(ptr);
} finally {
calloc.free(ptr);
}
}