detachAndDisposeDeferredSession function
Detach first so the replay worker drains before the session dies.
Implementation
void detachAndDisposeDeferredSession(Factory? session) {
if (session is! DeferredSessionFactory) {
return;
}
// Copied since a detach removes itself from the set.
for (final texture in session.attachedTextures.toList()) {
if (texture is RenderTexture && !texture.isDisposed) {
texture.useDeferredSession(null);
}
}
session.attachedTextures.clear();
session.attachedTexture = null;
session.dispose();
}