stillAnimating function

ScenarioStillAnimating stillAnimating(
  1. Settle policy, {
  2. String? verb,
  3. String? target,
  4. List<String> ticking = const [],
  5. bool ambient = false,
})

The sentence a strict step fails with, built where the facts are: which verb, what policy, and whatever announced work is still to land — which is the difference between "a spinner" and "a load the step did not wait for".

Implementation

ScenarioStillAnimating stillAnimating(
  Settle policy, {
  String? verb,
  String? target,
  List<String> ticking = const [],
  bool ambient = false,
}) {
  var did = [?verb, ?target].join(' ').trim();
  var budget = switch (policy) {
    _Budgeted(:var budget) => ' after ${_readable(budget)} of fake time',
    _ => '',
  };
  var pendingImages = PaintingBinding.instance.imageCache.pendingImageCount;
  var tracked = RealWork.pendingWork;
  var still = [
    if (pendingImages > 0)
      '$pendingImages image decode${pendingImages == 1 ? '' : 's'} pending',
    if (tracked.isNotEmpty)
      'tracked real work pending: ${tracked.map((w) => '`$w`').join(', ')}',
  ];
  if (ambient) {
    return ScenarioStillAnimating(
      '${did.isEmpty ? 'the step' : '`$did`'} left an `Ambient` on screen. '
      'Its motion is frozen in a scenario, so the screen settled, but '
      '`Settle.strict` fails any picture with a loader in it, frozen or not. '
      'If the loader belongs in this picture, say so on the verb: '
      '`settle: Settle.standard`.',
    );
  }
  return ScenarioStillAnimating(
    '${did.isEmpty ? 'the step' : '`$did`'} left the screen still '
    "animating: a frame was still scheduled$budget and after the step's "
    'real work had landed. `Settle.strict` fails the step here, where '
    '`Settle.standard` records `settled: false` and continues. '
    '${still.isEmpty ? 'No announced work is still in flight, so whatever keeps asking for frames is on the captured step: a spinner, a looping animation, or a caret in a focused field on an iOS device.' : 'Still in flight: ${still.join('; ')}.'} '
    '${ticking.isEmpty ? '' : 'Still ticking: ${ticking.join(', ')}. '}'
    'If the animation belongs in this picture, say so on the verb: '
    '`settle: Settle.standard`, or `Settle.frames(n)` for a fixed number of '
    'frames.',
  );
}