withRegistrationsAsync<T> static method

Future<T> withRegistrationsAsync<T>(
  1. Iterable<ChartRegistration> registrations,
  2. Future<T> body(), {
  3. bool clearBefore = false,
})

Async variant of withRegistrations.

Implementation

static Future<T> withRegistrationsAsync<T>(
  Iterable<ChartRegistration> registrations,
  Future<T> Function() body, {
  bool clearBefore = false,
}) async {
  final previous = snapshot();
  try {
    if (clearBefore) clear();
    registerAll(registrations);
    return await body();
  } finally {
    restore(previous);
  }
}