scope<R> static method
Installs a fresh MockShardObserver as the global observer for the
duration of body, then restores whatever observer was previously set
(including null) in a finally block.
Implementation
static Future<R> scope<R>(
Future<R> Function(MockShardObserver observer) body,
) async {
final previous = Shard.observer;
final observer = MockShardObserver();
Shard.observer = observer;
try {
return await body(observer);
} finally {
Shard.observer = previous;
}
}