sdlGetenv function
Get the value of a variable in the environment.
This function uses SDL's cached copy of the environment and is thread-safe.
\param name the name of the variable to get. \returns a pointer to the value of the variable or NULL if it can't be found.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL 3.1.3.
extern SDL_DECLSPEC const char * SDLCALL SDL_getenv(const char *name)
Implementation
String? sdlGetenv(String? name) {
final sdlGetenvLookupFunction = libSdl3.lookupFunction<
Pointer<Utf8> Function(Pointer<Utf8> name),
Pointer<Utf8> Function(Pointer<Utf8> name)>('SDL_getenv');
final namePointer = name != null ? name.toNativeUtf8() : nullptr;
final result = sdlGetenvLookupFunction(namePointer);
calloc.free(namePointer);
if (result == nullptr) {
return null;
}
return result.toDartString();
}