setUserId method
Buffered until the services exist — not merely until initialize has
been called: a host's unawaited initialize() followed by setUserId()
lands while they are still being built (review B6).
Implementation
Future<void> setUserId(String userId) async {
final services = _services;
if (services == null) {
// A blank ID is ignored here exactly as it is after init, so it can't
// replace a buffered clear with a no-op.
if (userId.trim().isEmpty) return;
_pendingClearUserId = false;
_pendingUserId = userId;
return;
}
await _applyUserId(services, userId);
}