generateClassBuilder function

ClassBuilder generateClassBuilder (ClassElement element, { Constructor injectedConstructor })

Implementation

ClassBuilder generateClassBuilder(ClassElement element,
    {Constructor injectedConstructor}) {
  return ClassBuilder()
    ..fields.add(Field((b) => b
      ..name = '_cache'
      ..type = refer('Map<String, dynamic>')
      ..modifier = FieldModifier.final$
      ..assignment = Code('Map<String, dynamic>()')))
    ..fields.add(Field((b) => b
      ..name = '_adapter'
      ..modifier = FieldModifier.final$
      ..type = refer('PreferenceAdapter')))
    ..name = "_\$${element.name}"
    ..implements.add(refer(element.name))
    ..constructors.add(
      injectedConstructor ??
          Constructor((b) => generateBasicConstructor(b, element.fields)),
    )
    ..methods.addAll(element.fields.map<Method>(generateAsyncGetter))
    ..methods.addAll(element.fields.map<Method>(generateAsyncSetter))
    ..methods.addAll(element.fields.map<Method>(generateSetter))
    ..methods.addAll(element.fields.map<Method>(generateGetter));
}