getHeaders property

FutureOr<Map<String, dynamic>?> Function()? getHeaders
final

Optional callback returning the headers for each connection attempt.

It is invoked (and awaited if it returns a future) on every connection and reconnection attempt, so authentication tokens can be refreshed between attempts. A non-null return value takes precedence over headers; when it returns null, headers is used:

SocketClientConfig(
  getHeaders: () => {'Authorization': 'Bearer ${authStore.currentToken}'},
)

Implementation

final FutureOr<Map<String, dynamic>?> Function()? getHeaders;