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}) async {
  List<Future<bool?>> extensionList = [
    CometChat.isExtensionEnabled("profanity-filter",
        onSuccess: (bool success) {
      debugPrint("profanity-filter has been enabled on dashboard");
    }, onError: (CometChatException exception) {
      if (onError != null) {
        onError(exception);
      }
      if (kDebugMode) {
        debugPrint(
            "Exception occurred while enabling profanity-filter extension: ${exception.details}");
      }
    }),
    CometChat.isExtensionEnabled("data-masking", onSuccess: (bool success) {
      debugPrint("data-masking has been enabled on dashboard");
    }, onError: (CometChatException exception) {
      if (onError != null) {
        onError(exception);
      }
      if (kDebugMode) {
        debugPrint(
            "Exception occurred while enabling  data-masking extension: ${exception.details}");
      }
    })
  ];
  List<bool?> results = await Future.wait(extensionList);
  if (results.contains(true)) {
    addExtension();

    if (onSuccess != null) {
      onSuccess(true);
    }
  }
}