Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: google/json_serializable.dart
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: MathGaps/json_serializable.dart
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 3 commits
  • 1 file changed
  • 1 contributor

Commits on Aug 2, 2022

  1. Copy the full SHA
    b99b56c View commit details

Commits on May 31, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9b6625f View commit details

Commits on Sep 4, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    d4ccec6 View commit details
Showing with 10 additions and 4 deletions.
  1. +10 −4 json_serializable/lib/src/type_helpers/to_from_string.dart
14 changes: 10 additions & 4 deletions json_serializable/lib/src/type_helpers/to_from_string.dart
Original file line number Diff line number Diff line change
@@ -15,8 +15,9 @@ final bigIntString = ToFromStringHelper(

final dateTimeString = ToFromStringHelper(
'DateTime.parse',
'toIso8601String()',
'toUtc().toIso8601String()',
'DateTime',
parseSuffix: '.toLocal()',
);

final uriString = ToFromStringHelper(
@@ -42,9 +43,11 @@ class ToFromStringHelper {
final String _toString;
final String coreTypeName;
final TypeChecker _checker;
final String? _parseSuffix;

ToFromStringHelper(this._parse, this._toString, this.coreTypeName)
: _checker = TypeChecker.fromUrl('dart:core#$coreTypeName');
ToFromStringHelper(this._parse, this._toString, this.coreTypeName, {String? parseSuffix})
: _checker = TypeChecker.fromUrl('dart:core#$coreTypeName'),
_parseSuffix = parseSuffix;

bool matches(DartType type) => _checker.isExactlyType(type);

@@ -76,7 +79,10 @@ class ToFromStringHelper {

final parseParam = isString ? expression : '$expression as String';

final output = '$_parse($parseParam)';
String output = '$_parse($parseParam)';
if (_parseSuffix != null) {
output = '$output$_parseSuffix';
}

return DefaultContainer(
expression,