hasDefaultConstructor static method

  1. @visibleForTesting
bool hasDefaultConstructor(
  1. ClassMirror classMirror
)

Returns true if the specified classMirror has a default (unnamed) constructor that accepts an empty arguments list.

Implementation

@visibleForTesting
static bool hasDefaultConstructor(mirrors.ClassMirror classMirror) {
  for (var declaration in classMirror.declarations.values) {
    if (declaration is mirrors.MethodMirror) {
      if (declaration.isConstructor &&
          declaration.constructorName == const Symbol('') &&
          declaration.parameters.every(_canBeOmitted)) {
        return true;
      }
    }
  }
  return false;
}