attachSurface method
Implementation
Future<void> attachSurface(Size size, double pixelRatio) async {
final bool changed = size != _viewSize || pixelRatio != _pixelRatio;
_viewSize = size;
_pixelRatio = pixelRatio;
if (_disposed || size.isEmpty) return;
if (_sessionId != null) {
if (changed) await _safe(() => _invoke("resize", _sizeArgs()));
return;
}
if (_creating || defaultTargetPlatform == TargetPlatform.iOS && !kIsWeb) return;
_creating = true;
value = value.copyWith(state: UArSessionState.initializing);
try {
final Map<Object?, Object?> raw = await UArChannel.invokeMap("create", <String, Object?>{"config": config.toMap(), ..._sizeArgs()}) ?? const <Object?, Object?>{};
final int id = _i(raw["sessionId"], -1);
if (id < 0) throw const UArException(code: UArErrorCode.sessionFailed, message: "No session id");
value = value.copyWith(textureId: raw["textureId"] is num ? _i(raw["textureId"]) : null, viewType: raw["viewType"] as String?);
await _start(id);
} on UArException catch (error) {
_fail(error);
} finally {
_creating = false;
}
}