Skip to content

Fix Dart formatting in JSON strings, standardized strings, etc #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 2, 2017

Conversation

kevmoo
Copy link
Collaborator

@kevmoo kevmoo commented Aug 1, 2017

No description provided.

preparing to enable lint: prefer_single_quotes
@kevmoo kevmoo requested a review from natebosch August 1, 2017 21:44

return '$marked _\$${element.displayName}JsonLiteral = $thing;';
}
}

bool _isConstType(value) {
return value == null || value is String || value is num || value is bool;
String _jsonLiteralAsDart(dynamic value, bool asConst) {
Copy link
Member

Choose a reason for hiding this comment

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

maybe break out some methods?

This is really hard to follow. Also a Doc comment would be nice

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

PTAL

/// literal.
String _jsonLiteralAsDart(dynamic value, bool asConst) {
if (value == null) {
return 'null';
Copy link
Member

Choose a reason for hiding this comment

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

It might read easier if we don't use the else after a return. Also could optionally inline the return

if (value == null) return 'null';
if (value is String) return _jsonStringAsDart(value);
if (value is bool || value is num) {
  return value.toString();
}
if (value is List) return _jsonListAsDart(value, asConst);
if (value is Map) return _jsonMapAsDart(value, asConst);
throw ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I generally like closing braces...but I see your point...

Fix edge cases with String encoding in JsonLiteral generator
And add tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants