Superwall

configure()

A static method that configures the Superwall SDK with your API key.

This method is typically called once in your app's initialization, such as in your main() function or during app startup.

Purpose

Configures the Superwall SDK with your API key and optional configuration settings.

Signature

static Superwall configure(
  String apiKey, {
  PurchaseController? purchaseController,
  SuperwallOptions? options,
  Function? completion,
})

Parameters

NameTypeDescription
apiKeyStringYour Superwall API key from the dashboard.
purchaseControllerPurchaseController?Optional custom purchase controller. Defaults to null to use the default controller.
optionsSuperwallOptions?Optional configuration options. Defaults to null for default settings.
completionFunction?Optional callback called when configuration completes.

Returns / State

Returns a Superwall instance that is immediately configured and ready to use.

Usage

Basic configuration:

import 'package:superwallkit_flutter/superwallkit_flutter.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  Superwall.configure('pk_your_api_key_here');
  
  runApp(MyApp());
}

With options:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  final options = SuperwallOptions(
    paywalls: PaywallOptions(
      shouldPreload: true,
      automaticallyDismiss: false,
    ),
    logging: Logging(
      level: LogLevel.debug,
    ),
  );
  
  Superwall.configure(
    'pk_your_api_key_here',
    options: options,
  );
  
  runApp(MyApp());
}

With completion callback:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  Superwall.configure(
    'pk_your_api_key_here',
    completion: () {
      print('Superwall configuration completed');
    },
  );
  
  runApp(MyApp());
}

How is this guide?

On this page