isAIFeatureEnabled static method

Future<void> isAIFeatureEnabled(
  1. String feature,
  2. {required dynamic onSuccess(
    1. bool isEnabled
    ),
  3. required dynamic onError(
    1. CometChatException e
    )}
)

Implementation

static Future<void> isAIFeatureEnabled(String feature, {required Function(bool isEnabled) onSuccess, required Function(CometChatException e) onError}) async{
  try{
    if(feature.isEmpty){
      onError(CometChatException(ErrorCode.errorEmptyFeature, ErrorMessage.errorEmptyFeature, ErrorMessage.errorEmptyFeature));
    }else{
      final arguments = {
        "feature": feature
      };
      final result = await channel.invokeMethod('isAIFeatureEnabled', arguments);
      onSuccess(result);
    }
  } on PlatformException catch (e) {
    debugPrint("Error: $e");
    onError(CometChatException(e.code, e.details, e.message));
  } catch (e) {
    debugPrint("Error: $e");
    onError(CometChatException(ErrorCode.errorUnhandledException, e.toString() , e.toString()));
  }
}