addPlugin method

Future<void> addPlugin(
  1. P plugin
)

Adds a plugin to the category.

Implementation

Future<void> addPlugin(P plugin) async {
  //TODO: Allow for multiple plugins to work simultaneously
  if (plugins.isEmpty) {
    try {
      await plugin.addPlugin();
      plugins.add(plugin);
    } on AmplifyAlreadyConfiguredException {
      plugins.add(plugin);
    } on AmplifyException {
      rethrow;
    } on Exception catch (e) {
      throw AmplifyException(e.toString());
    }
  } else {
    throw AmplifyException(
      '${category.name} plugin has already been added, '
      'multiple plugins for ${category.name} category are currently not supported.',
    );
  }
}