detach<T> method

T? detach<T>()

Detaches a contextual value from this instance and returns it, or null if it didn't exist. The type of T is the signature/key of what will be removed if it exists. This won't throw if the value was NOT previously attached.

Implementation

T? detach<T>() {
  final key = T.runtimeType.toString();
  if (_context.containsKey(key)) {
    return _context.remove(key) as T?;
  }
  return null;
}