publicFieldNames property Null safety

List<String> publicFieldNames

Implementation

List<String> get publicFieldNames {
  final instanceMembers = classMirror!.instanceMembers;
  return instanceMembers.values
      .where((MethodMirror method) {
        final isGetterAndSetter = method.isGetter &&
            classMirror!.instanceMembers[method.simpleName + '='] != null;
        final isPublicGetter = method.isGetter &&
            !method.isRegularMethod &&
            !['hashCode', 'runtimeType'].contains(method.simpleName);
        return (method.isGetter &&
                (method.isSynthetic ||
                    (isGetterAndSetter || isPublicGetter))) &&
            !method.isPrivate;
      })
      .map((MethodMirror method) => method.simpleName)
      .toList();
}