getDeclarationType method

Type getDeclarationType (
  1. DeclarationMirror mirror
)

Implementation

Type getDeclarationType(DeclarationMirror mirror) {
  var result = dynamic;
  VariableMirror variable;
  MethodMirror method;

  try {
    variable = mirror as VariableMirror;
    result = variable.hasReflectedType ? variable.reflectedType : null;
  } catch (error) {
    result = result;
  }

  try {
    method = mirror as MethodMirror;
    result =
        method.hasReflectedReturnType ? method.reflectedReturnType : null;
  } catch (error) {
    result = result;
  }

  return result ??= dynamic;
}