createWithAreaCode method Null safety

Future<RtcEngine> createWithAreaCode(
  1. String appId,
  2. List<AreaCode> areaCode

Creates an RtcEngine instance.


This method is deprecated since v3.3.1.

Unless otherwise specified, all the methods provided by the RtcEngine class are executed asynchronously. Agora recommends calling these methods in the same thread.


  • You must create an RtcEngine instance before calling any other method.
  • You can create an RtcEngine instance either by calling this method or by calling RtcEngine.create. The difference between RtcEngine.create and this method is that this method enables you to specify the connection area.
  • The Agora RTC Native SDK supports creating only one RtcEngine instance for an app for now.

Parameter appId The App ID issued to you by Agora. See How to get the App ID. Only users in apps with the same App ID can join the same channel and communicate with each other. Use an App ID to create only one RtcEngine instance. To change your App ID, call destroy to destroy the current RtcEngine instance and after destroy returns 0, call create to create an RtcEngine instance with the new App ID.

Parameter areaCode The area of connection. This advanced feature applies to scenarios that have regional restrictions.

For details, see AreaCode.

After specifying the area of connection:

  • When the app that integrates the Agora SDK is used within the specified area, it connects to the Agora servers within the specified area under normal circumstances.
  • When the app that integrates the Agora SDK is used out of the specified area, it connects to the Agora servers either in the specified area or in the area where the app is located.


  • An RtcEngine instance if the method call succeeds.
  • The error code, if this method call fails:


static Future<RtcEngine> createWithAreaCode(
    String appId, List<AreaCode> areaCode) {
  return createWithContext(RtcEngineContext(appId, areaCode: areaCode));