Skip to content

Commit

Permalink
build(mek_data_class_generator): release 1.3.1
Browse files Browse the repository at this point in the history
fix: private fields class generation
  • Loading branch information
BreX900 authored and SimoneBressan committed Jun 10, 2023
1 parent b3427da commit 6836ec2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions mek_data_class_generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 1.3.1
- fix: private fields class generation

## 1.3.0
- fix: unnecessary parentheses on `toString` method [#20](https://github.com/BreX900/data_class/issues/20)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class FieldsClassCreator extends Creator {
yield createLibraryClassFields();
}

String get _classPrefix => config.fieldsClassVisible ? '' : '_';

String _createFieldPath(FieldSpec fieldSpec, bool hasFieldMap) {
return hasFieldMap ? '\$_path\${_get(\'${fieldSpec.name}\')}' : '\${_path}${fieldSpec.name}';
}
Expand All @@ -42,7 +44,7 @@ class FieldsClassCreator extends Creator {
final fieldClassSpec = ClassSpec.from(config, fieldClassElement, fieldClassReader);
if (!fieldClassSpec.createFieldsClass) return null;

final keysClassName = '${fieldClassElement.name}Fields';
final keysClassName = '$_classPrefix${fieldClassElement.name}Fields';

return Method((b) => b
..returns = Reference(keysClassName)
Expand All @@ -56,7 +58,7 @@ class FieldsClassCreator extends Creator {
final jsonSerializable = _jsonSerializableType.firstAnnotationOf(classSpec.element);
final hasFieldMap = ConstantReader(jsonSerializable).peek('createFieldMap')?.boolValue ?? false;

final className = '${config.fieldsClassVisible ? '' : '_'}${classSpec.element.name}Fields';
final className = '$_classPrefix${classSpec.element.name}Fields';

final methodsFields = _paramsSpecs.map((field) {
final fieldPath = _createFieldPath(field, hasFieldMap);
Expand Down
2 changes: 1 addition & 1 deletion mek_data_class_generator/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: mek_data_class_generator
version: 1.3.0
version: 1.3.1
description: >
Code generator for data_class to generate `hashCode`, `==`, `toString`, `copyWith`
and `change` methods
Expand Down

0 comments on commit 6836ec2

Please sign in to comment.