updatePresence method Null safety

void updatePresence(
  1. DiscordPresence presence
)

Updates the presence of the DiscordUser, takes DiscordPresence as argument. Describing current user presence inside the application or game.

For showing the user's start time from present, you must pass DiscordPresence.startTimeStamp as DateTime.now().millisecondsSinceEpoch.

Implementation

void updatePresence(DiscordPresence presence) {
  var presencePtr = calloc<ffi.DiscordRichPresence>();
  presencePtr.ref.state = (presence.state ?? '').toNativeUtf8();
  presencePtr.ref.details = (presence.details ?? '').toNativeUtf8();
  presencePtr.ref.startTimestamp = presence.startTimeStamp ?? 0;
  presencePtr.ref.endTimestamp = presence.endTimeStamp ?? 0;
  presencePtr.ref.largeImageKey =
      (presence.largeImageKey ?? '').toNativeUtf8();
  presencePtr.ref.largeImageText =
      (presence.largeImageText ?? '').toNativeUtf8();
  presencePtr.ref.smallImageKey =
      (presence.smallImageKey ?? '').toNativeUtf8();
  presencePtr.ref.smallImageText =
      (presence.smallImageText ?? '').toNativeUtf8();
  presencePtr.ref.partySize = presence.partySize ?? 0;
  presencePtr.ref.matchSecret = (presence.matchSecret ?? '').toNativeUtf8();
  presencePtr.ref.joinSecret = (presence.joinSecret ?? '').toNativeUtf8();
  presencePtr.ref.spectateSecret =
      (presence.spectateSecret ?? '').toNativeUtf8();
  presencePtr.ref.instance = presence.instance ?? 0;
  _bindings.Discord_UpdatePresence(presencePtr);
  calloc.free(presencePtr);
}