sync method
The Sync panel: each source's entities and self-description, and the latest status each entity reported.
A source describes itself only if it implements DevtoolsInspectable.
While the cache is changing principal, once the inspector is disposed,
and when either happens while a source is being asked, the answer is
empty and stale is true: nothing a source said for the previous
principal is returned.
Implementation
Future<Map<String, Object?>> sync() async {
if (!_answerable()) return _staleSync();
final epoch = _session;
final sources = <Map<String, Object?>>[];
for (final source in _dev.syncSources) {
Object? detail;
if (source case final DevtoolsInspectable inspectable) {
try {
final described = await inspectable.describeForDevtools();
if (_moved(epoch)) return _staleSync();
detail = bounded(described, 50);
} on Object catch (error) {
if (_moved(epoch)) return _staleSync();
detail = {'error': shortMessage('$error')};
}
}
sources.add({
'type': source.runtimeType.toString(),
'entities': [...source.entities]..sort(),
'detail': detail,
});
}
return {
'sources': sources,
'entities': [for (final entry in _sync.entries()) entry.toJson()],
};
}