addPlugin method

void addPlugin(
  1. Plugin plugin, {
  2. Map<String, dynamic>? settings,
})

Adds a new plugin to the currently loaded set. @param {{ plugin: Plugin, settings?: IntegrationSettings }} Plugin to be added. Settings are optional if you want to force a configuration instead of the Segment Cloud received one

Implementation

void addPlugin(Plugin plugin, {Map<String, dynamic>? settings}) {
  // plugins can either be added immediately or
  // can be cached and added later during the next state update
  // this is to avoid adding plugins before network requests made as part of setup have resolved
  if (settings != null && plugin.type == PluginType.destination) {
    state.integrations
        .addIntegration((plugin as DestinationPlugin).key, settings);
  }

  if (!state.isReady) {
    _pluginsToAdd.add(plugin);
  } else {
    _addPlugin(plugin);
  }
}