setUp static method

Future<void> setUp(
  1. ACRCloudConfig config
)

Set up ACRCloud according to the ACRCloudConfig passed.

You only need to call this function once; subsequent calls will be ignored.

Implementation

static Future<void> setUp(ACRCloudConfig config) async {
  if (_isSetUp) {
    return;
  }

  _channel.setMethodCallHandler((call) async {
    if (call.method == 'volume') {
      _session?._volume.add(call.arguments);
    } else if (call.method == 'result') {
      _session?._result
          .complete(ACRCloudResponse.fromJson(json.decode(call.arguments)));
    }
  });

  await _channel.invokeMethod('setUp', {
    'accessKey': config.accessKey,
    'accessSecret': config.accessSecret,
    'host': config.host
  });

  _isSetUp = true;
}