createWithContext method Null safety

Future<RtcEngine> createWithContext(
  1. RtcEngineContext context

Creates an RtcEngine instance and specifies one or multiple connection areas.

Since v4.0.5

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


  • You must create the RtcEngine instance before calling any other method.
  • The Agora RTC Native SDK supports creating only one RtcEngine instance for an app for now.

Parametercontext Configurations for the RtcEngine instance. For details, see RtcEngineContext.


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


static Future<RtcEngine> createWithContext(RtcEngineContext context) async {
  if (_instance != null) return _instance!;
  _instance = RtcEngine._();
  await _instance!._invokeMethod('create', {
    'config': context.toJson(),
    'appType': 4,
  return _instance!;