init static method

void init({
  1. required String stateDir,
  2. TailscaleLogLevel logLevel = TailscaleLogLevel.silent,
})

Configures the Tailscale library. Call this once at app startup, alongside other library initializers.

stateDir is an app-owned directory where Tailscale persists its node identity, keys, and profile data under a tailscale/ subdirectory. Pick somewhere durable — on Flutter, the application_documents_directory is a good default. On a fresh install this directory is empty; after the first successful up, it contains credentials that let subsequent launches reconnect without an auth key.

Implementation

static void init({
  required String stateDir,
  TailscaleLogLevel logLevel = TailscaleLogLevel.silent,
}) {
  if (stateDir.trim().isEmpty) {
    throw const TailscaleUsageException('stateDir must not be empty.');
  }
  final normalizedStateDir = p.normalize(p.absolute(stateDir));

  try {
    ensurePosixFdTransportAvailable();
  } catch (error) {
    throw TailscaleUsageException(
      'POSIX fd transport is not available on this platform.',
      cause: error,
    );
  }

  _stateBaseDir = normalizedStateDir;
  native.duneSetLogLevel(logLevel.nativeValue);
}