setProperty static method

  1. @Deprecated('Use "Countly.instance.userProfile.setProperty" instead')
Future<String?> setProperty(
  1. String keyName,
  2. String keyValue
)

Implementation

@Deprecated('Use "Countly.instance.userProfile.setProperty" instead')
static Future<String?> setProperty(String keyName, String keyValue) async {
  if (!_instance._countlyState.isInitialized) {
    String message = '"initWithConfig" must be called before "setProperty"';
    log('setProperty, $message', logLevel: LogLevel.ERROR);
    return message;
  }
  log('Calling "setProperty":[$keyName], value:[$keyValue]');
  if (keyName.isEmpty) {
    String error = 'setProperty, key cannot be empty';
    log(error);
    return 'Error : $error';
  }
  if (keyValue.isEmpty) {
    String error = 'setProperty, value cannot be empty';
    log(error);
    return 'Error : $error';
  }
  List<String> args = [];
  args.add(keyName);
  args.add(keyValue);

  final String? result = await _channel.invokeMethod('userData_setProperty', <String, dynamic>{'data': json.encode(args)});

  return result;
}