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.