enable method

  1. @override
void enable({
  1. dynamic onSuccess(
    1. bool success
    )?,
  2. dynamic onError(
    1. CometChatException exception
    )?,
})
override

Method to populate data source

Implementation

@override
void enable(
    {Function(bool success)? onSuccess,
    Function(CometChatException exception)? onError}) {
  CometChat.isAIFeatureEnabled(getExtensionId(), onSuccess: (bool success) {
    if (kDebugMode) {
      print("enabling extension id ${getExtensionId()} status $success");
    }

    if (success) {
      addExtension();
    }
    if (onSuccess != null) {
      onSuccess(success);
    }
  }, onError: (CometChatException exception) {
    if (onError != null) {
      onError(exception);
    }
    if (kDebugMode) {
      debugPrint(
          "Exception occurred while enabling ${getExtensionId()} extension: ${exception.details}");
    }
  });
}