-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: tristate_optionals - defining originalSymbolName
- Loading branch information
Showing
11 changed files
with
185 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class CustomDate extends DateTime { | ||
CustomDate( | ||
super.year, | ||
super.month, | ||
super.day, | ||
); | ||
|
||
static CustomDate parse(String formattedString) { | ||
final DateTime dateTime = DateTime.parse(formattedString); | ||
return CustomDate(dateTime.year, dateTime.month, dateTime.day); | ||
} | ||
|
||
@override | ||
CustomDate toLocal() { | ||
final DateTime localDateTime = super.toLocal(); | ||
return CustomDate( | ||
localDateTime.year, localDateTime.month, localDateTime.day); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
codegen/end_to_end_test_tristate/lib/custom_date_serializer.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:built_value/serializer.dart'; | ||
import 'package:end_to_end_test_tristate/custom_date.dart'; | ||
|
||
class CustomDateSerializer implements PrimitiveSerializer<CustomDate> { | ||
@override | ||
CustomDate deserialize( | ||
Serializers serializers, | ||
Object serialized, { | ||
FullType specifiedType = FullType.unspecified, | ||
}) { | ||
assert(serialized is String, | ||
"CustomDateSerializer expected 'String' but got ${serialized.runtimeType}"); | ||
return CustomDate.parse(serialized as String).toLocal(); | ||
} | ||
|
||
@override | ||
String serialize( | ||
Serializers serializers, | ||
CustomDate date, { | ||
FullType specifiedType = FullType.unspecified, | ||
}) { | ||
return date.toUtc().toIso8601String().split('T').first; | ||
} | ||
|
||
@override | ||
Iterable<Type> get types => [CustomDate]; | ||
|
||
@override | ||
String get wireName => 'Date'; | ||
} |
22 changes: 18 additions & 4 deletions
22
codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.ast.gql.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
48 changes: 29 additions & 19 deletions
48
codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.