Google is committed to advancing racial equity for Black communities. See how.

snapshot method

*<Null safety>*

Future<List<DiagnosticsData<METADATA>>> snapshot ({bool acceptSnapshot(List<DiagnosticsData<METADATA>> snapshot), Duration attemptDelay: const Duration(milliseconds: 100), int? maxAttempts: 200})

Obtain a snapshot of the current inspect data as constrained by selector.

The return value is the json object returned by FormattedContent.json as parsed by jsonDecode.

If acceptSnapshot is not null, this method returns a snapshot once acceptSnapshot returns true. If maxAttempts is not null, at most maxAttempts are made to obtain a snapshot. delay controls the delay between snapshot attempts.


Future<List<DiagnosticsData<METADATA>>> snapshot(
    {bool acceptSnapshot(List<DiagnosticsData<METADATA>> snapshot)?,
    Duration attemptDelay = const Duration(milliseconds: 100),
    int? maxAttempts = 200}) async {
  for (var attempts = 0;
      maxAttempts == null || attempts < maxAttempts;
      attempts++) {
    final snapshot = await _snapshotAttempt;
    if (acceptSnapshot == null || acceptSnapshot(snapshot)) {
      return snapshot;
    await Future.delayed(attemptDelay);
  throw Exception('snapshot failed');