0

I am using package:analyzer to do custom static analysis.

when I have dart code like below :

class MyType{

    final void Function(MyItemType) callback ;
}

When I try to access the element of the callback type : I am getting null

That is :

parameterElement.type.element evaluates to be null . Therefore I cannot get the source file of the Types involved in the Function to import those source files.

This issue happens only when I use a Function type that is anything other than just Function().

parameterElement is of Type ParameterElement from analyser package.

My requirement is that I want to import all the files that contain the Types involved in the Function. In my example code shown above , I wish to import the file that contains the MyItemType class.

Also if the return type of the function was some other Type other than void , I want to import the corresponding source file.

Natesh bhat
  • 12,274
  • 10
  • 84
  • 125
  • What are `parameterElement`, `element`, and `source`? Are they members of some class you haven't provided code for? – jamesdlin May 07 '20 at 06:35
  • Ahh, you're using `package:analyzer` to do custom static analysis of that code; you're not *running* `dartanalyzer`. Your question would be clearer if it explained that at the beginning. – jamesdlin May 07 '20 at 07:01

0 Answers0