enableEncryption method Null safety

Future<void> enableEncryption(
  1. bool enabled,
  2. EncryptionConfig config

Enables/Disables the built-in encryption.

In scenarios requiring high security, Agora recommends calling enableEncryption to enable the built-in encryption before joining a channel.

All users in the same channel must use the same encryption mode and encryption key. Once all users leave the channel, the encryption key of this channel is automatically cleared.


  • If you enable the built-in encryption, you cannot use the RTMP or RTMPS streaming function.
  • Agora supports four encryption modes. If you choose an encryption mode (excepting SM4128ECB mode), you need to add an external encryption library when integrating the SDK. For details, see the advanced guide Channel Encryption.

Parameter enabled Whether to enable the built-in encryption.

  • true: Enable the built-in encryption.
  • false: Disable the built-in encryption. Parameter config Configurations of built-in encryption schemas. See EncryptionConfig.


Future<void> enableEncryption(bool enabled, EncryptionConfig config) {
  return _invokeMethod('enableEncryption', {
    'enabled': enabled,
    'config': config.toJson(),