snapshot method
Implementation
Future<PatchbayInvocation> snapshot({
int maxDepth = 64,
int maxNodes = 1000,
String? requestId,
}) async {
final String id = requestId ?? _newRequestId();
final List<String> outOfRange = <String>[
if (maxDepth < 0) 'maxDepth',
if (maxNodes < 1 || maxNodes > 10000) 'maxNodes',
];
if (outOfRange.isNotEmpty) {
return PatchbayInvocation.rejected(
requestId: id,
rejection: PatchbayRejection(
code: 'invalidUiTreeLimits',
notice:
'maxDepth must be non-negative and maxNodes must be 1..10000.',
details: <String, Object?>{'invalid': outOfRange},
),
);
}
final PatchbayInvocation? gate = await patchbaySemanticsGateFence(
_gates,
requestId: id,
gateIds: const <String>{},
);
if (gate != null) return gate;
final PatchbayInvocation? lifecycle = _fence.evaluate(id);
if (lifecycle != null) return lifecycle;
final SemanticsOwner? owner = await ensureOwner();
final SemanticsNode? root = owner?.rootSemanticsNode;
if (owner == null || root == null) {
return PatchbayInvocation.rejected(
requestId: id,
rejection: const PatchbayRejection(code: 'uiSemanticsUnavailable'),
);
}
final PatchbaySemanticsSnapshot snapshot = _buildSnapshot(
root,
maxDepth: maxDepth,
maxNodes: maxNodes,
);
return PatchbayInvocation.accepted(
requestId: id,
payload: snapshot.toJson(_treeRevision),
);
}