initialize static method

Future<void> initialize({
  1. required SupabaseClient client,
  2. String? authPersistencePath,
  3. String? appVersion,
})

Initialize the Supabase Addons

It automatically defines the Auth Persistent Storage location and the App Version (used by analytics), if not provided.

Implementation

static Future<void> initialize({
  required SupabaseClient client,
  String? authPersistencePath,
  String? appVersion,
}) async {
  WidgetsFlutterBinding.ensureInitialized();

  // The documents directory is where the user auth information is going
  // to be stored
  final persistencePath = authPersistencePath ??
      await () async {
        final documentsDir = await getApplicationDocumentsDirectory();
        return '${documentsDir.path}/auth';
      }();

  // Get the current app info. This is used by analytics to determine the
  // current app version
  final version = appVersion ?? (await PackageInfo.fromPlatform()).version;

  return SupabaseAddons.initialize(
    client: client,
    authPersistencePath: persistencePath,
    appVersion: version,
  );
}