currentUid function

String? currentUid()

The signed-in uid, or null.

Implementation

String? currentUid() {
  // A build with with_firebase: false contains no auth symbols, and the
  // resolver's "Couldn't resolve native function" says nothing about why.
  // Every entry point below checks first, so the answer names the cause.
  if (!hasFirebase) return null;
  const cap = 256;
  final buf = calloc<Uint8>(cap);
  try {
    final len = fdbAuthCurrentUid(buf.cast(), cap);
    if (len <= 0) return null;
    return buf.cast<Utf8>().toDartString(length: len);
  } finally {
    calloc.free(buf);
  }
}