-
Notifications
You must be signed in to change notification settings - Fork 412
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
Conversation
preparing to enable lint: prefer_single_quotes
lib/src/json_literal_generator.dart
Outdated
|
||
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PTAL
lib/src/json_literal_generator.dart
Outdated
/// literal. | ||
String _jsonLiteralAsDart(dynamic value, bool asConst) { | ||
if (value == null) { | ||
return 'null'; |
There was a problem hiding this comment.
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 ...
There was a problem hiding this comment.
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
No description provided.