Skip to content

[pigeon] allow empty class#12181

Open
tarrinneal wants to merge 1 commit into
flutter:mainfrom
tarrinneal:allow-empty-class
Open

[pigeon] allow empty class#12181
tarrinneal wants to merge 1 commit into
flutter:mainfrom
tarrinneal:allow-empty-class

Conversation

@tarrinneal

Copy link
Copy Markdown
Contributor

instead of preventing it from being defined, I just made it work

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for empty data classes in Pigeon across Dart, Java, Kotlin, and Objective-C generators, and bumps the package version to 27.2.0. Feedback on the changes suggests adding a blank line between the constructor and the serialization method in the generated Dart code for empty classes to improve readability.

Comment on lines +229 to 238
if (classDefinition.fields.isNotEmpty) {
indent.newln();
for (final NamedType field in getFieldsInSerializationOrder(classDefinition)) {
addDocumentationComments(indent, field.documentationComments, docCommentSpec);

final String datatype = addGenericTypes(field.type);
indent.writeln('$datatype ${field.name};');
indent.newln();
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When generating Dart code for an empty class, there is no blank line written between the constructor and the _writeToList method. Adding a blank line here improves the readability of the generated code and aligns with Dart style guidelines for class member spacing.

Suggested change
if (classDefinition.fields.isNotEmpty) {
indent.newln();
for (final NamedType field in getFieldsInSerializationOrder(classDefinition)) {
addDocumentationComments(indent, field.documentationComments, docCommentSpec);
final String datatype = addGenericTypes(field.type);
indent.writeln('$datatype ${field.name};');
indent.newln();
}
}
if (classDefinition.fields.isNotEmpty) {
indent.newln();
for (final NamedType field in getFieldsInSerializationOrder(classDefinition)) {
addDocumentationComments(indent, field.documentationComments, docCommentSpec);
final String datatype = addGenericTypes(field.type);
indent.writeln('$datatype ${field.name};');
indent.newln();
}
} else {
indent.newln();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant