getClassDeclarationFromType method Null safety

Future<ClassDeclaration?> getClassDeclarationFromType(
  1. Type type
)

Implementation

Future<ClassDeclaration?> getClassDeclarationFromType(Type type) async {
  final classMirror = reflectType(type);
  Uri uri = classMirror.location!.sourceUri;
  if (!classMirror.location!.sourceUri.isAbsolute) {
    final Package? package = await getPackageFromUri(uri);
    uri = package!.packageUriRoot;
  }
  return analyzer.getClassFromFile(
    MirrorSystem.getName(classMirror.simpleName),
    uri,
  );
}