sdlShowAndroidToast function
Shows an Android toast notification.
Toasts are a sort of lightweight notification that are unique to Android.
https://developer.android.com/guide/topics/ui/notifiers/toasts
Shows toast in UI thread.
For the gravity
parameter, choose a value from here, or -1 if you don't
have a preference:
https://developer.android.com/reference/android/view/Gravity
\param message text message to be shown. \param duration 0=short, 1=long. \param gravity where the notification should appear on the screen. \param xoffset set this parameter only when gravity >=0. \param yoffset set this parameter only when gravity >=0. \returns true on success or false on failure; call SDL_GetError() for more information.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL 3.1.3.
extern SDL_DECLSPEC bool SDLCALL SDL_ShowAndroidToast(const char *message, int duration, int gravity, int xoffset, int yoffset)
Implementation
bool sdlShowAndroidToast(
String? message, int duration, int gravity, int xoffset, int yoffset) {
final sdlShowAndroidToastLookupFunction = libSdl3.lookupFunction<
Uint8 Function(Pointer<Utf8> message, Int32 duration, Int32 gravity,
Int32 xoffset, Int32 yoffset),
int Function(Pointer<Utf8> message, int duration, int gravity,
int xoffset, int yoffset)>('SDL_ShowAndroidToast');
final messagePointer = message != null ? message.toNativeUtf8() : nullptr;
final result = sdlShowAndroidToastLookupFunction(
messagePointer, duration, gravity, xoffset, yoffset) ==
1;
calloc.free(messagePointer);
return result;
}