dart_discord_presence library

Dart Discord Presence - Discord Rich Presence for Flutter/Dart desktop applications.

This package provides Discord Rich Presence functionality for Flutter apps on Windows, macOS, and Linux using pure Dart (no native code required).

Quick Start

import 'package:dart_discord_presence/dart_discord_presence.dart';

void main() async {
  if (!DiscordRPC.isAvailable) {
    print('Discord RPC not available on this platform');
    return;
  }

  final discord = DiscordRPC();

  discord.onReady.listen((event) {
    print('Connected as ${event.user.username}');
  });

  await discord.initialize('YOUR_APPLICATION_ID');

  await discord.setPresence(DiscordPresence(
    state: 'Playing Solo',
    details: 'In Main Menu',
    largeAsset: DiscordAsset(key: 'app_icon', text: 'My App'),
  ));
}

Classes

DiscordAsset
Image asset configuration for presence display.
DiscordButton
A clickable button shown on the presence card (max 2 buttons).
DiscordDisconnectedEvent
Emitted when connection to Discord is lost.
DiscordErrorEvent
Emitted when an error occurs.
DiscordEvent
Base class for all Discord RPC events.
DiscordJoinGameEvent
Emitted when a user clicks "Join" on the presence.
DiscordJoinRequestEvent
Emitted when a user requests to join the game.
DiscordParty
Party configuration for multiplayer presence.
DiscordPresence
Represents Discord Rich Presence data.
DiscordReadyEvent
Emitted when connection to Discord is established.
DiscordRPC
Discord Rich Presence client for Flutter/Dart desktop applications.
DiscordSecrets
Secrets for join/spectate functionality.
DiscordSpectateGameEvent
Emitted when a user clicks "Spectate" on the presence.
DiscordTimestamps
Timestamp configuration for presence display.
DiscordUser
Represents a Discord user.

Enums

DiscordActivityType
Discord activity types that determine how the presence is displayed.
DiscordPartyPrivacy
Party privacy settings.
DiscordRPCState
Connection state of the Discord RPC client.
DiscordStatusDisplayType
Controls which field is displayed in the user's status text in the member list.
JoinRequestReply
Reply options for join requests.

Exceptions / Errors

DiscordConnectionException
Thrown when the connection to Discord fails or is lost.
DiscordNotRunningException
Thrown when Discord is not running or the IPC socket is unavailable.
DiscordProtocolException
Thrown when there's a protocol error (invalid frame, parse error, etc).
DiscordRPCException
Base exception for Discord RPC errors.
DiscordStateException
Thrown when an operation is attempted in an invalid state.