init static method

Future<Unleash> init(
  1. UnleashSettings settings, {
  2. UnleashClient? client,
  3. UpdateCallback? onUpdate,
  4. ToggleBackup? toggleBackup,
})

Initializes an Unleash instance, registers it at the backend and starts to load the feature toggles. settings are used to specify the backend and various other settings. A client can be used for example to further configure http headers according to your needs.

Implementation

static Future<Unleash> init(
  UnleashSettings settings, {
  UnleashClient? client,
  UpdateCallback? onUpdate,
  ToggleBackup? toggleBackup,
}) async {
  final unleash = Unleash._internal(
    settings,
    onUpdate,
    client ?? UnleashClient(settings: settings, client: http.Client()),
    toggleBackup,
  );

  unleash._activationStrategies.addAll(settings.strategies ?? []);

  await unleash._register();
  await unleash._loadToggles();
  unleash._setTogglePollingTimer();
  return unleash;
}