classMirrorForInstance method

ClassMirror? classMirrorForInstance(
  1. Object? instance
)

Implementation

ClassMirror? classMirrorForInstance(Object? instance) {
  TypeMirror? result = typeMirrorForType(instance.runtimeType);
  if (result is ClassMirror) return result;
  // Check if we have a generic class that matches.
  for (TypeMirror typeMirror in _typeToTypeMirrorCache!.values) {
    if (typeMirror is GenericClassMirrorImpl) {
      if (typeMirror._isGenericRuntimeTypeOf(instance)) {
        return _createInstantiatedGenericClass(
          typeMirror,
          instance.runtimeType,
          null,
        );
      }
    }
  }
  // Inform the caller that this object has no coverage.
  return null;
}