run<T> method

Future<T> run<T>(
  1. Future<T> operation()
)

Runs an asynchronous operation in a new Zone carrying this context.

This is the preferred way to activate a context for asynchronous code as it ensures that all asynchronous callbacks throughout the Future chain will correctly inherit this context via the Zone mechanism.

Implementation

Future<T> run<T>(Future<T> Function() operation) {
  return runZoned(
    operation,
    zoneValues: {_zoneKey: this},
  );
}