-
Notifications
You must be signed in to change notification settings - Fork 388
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
Support for Records #1222
Comments
I'm not thinking about this too much (yet) – but a good thing to discuss early! |
Probably worth reviving now that records reached stable? |
Yes, it's definitely needed now. I'm actually trying JsonKey.toJson and JsonKey.fromJson to use custom conversion on an annotated field which is a list of records. If I do this: |
Hrm...perhaps... I'm a bit nervous about the effort required here. I could dig a bit. |
I've just upgraded to Dart 3.0 and encountered this problem while generating mocks (using Mockito):
I've set
in |
You need to get the latest |
On the way - #1314 |
awesome! |
Umm... I have:
and
in and
in but I still get the error:
|
You need to change your SDK constraint to |
I have it already. |
Have you run |
You should NOT need to tweak analysis_options – that won't help the generator! |
Thank you. I removed:
from
from |
But now the problem is different - in generated file, it generated the imports as:
but in generated method: _i4.Future<({Uint8List data, InternetAddress dA})> findIp({ it did not replaced the prefixes, so the file does not compile |
This looks like a bug in |
I was kind of hoping for [0.34, 0.123, 0.542, 0.4143] it would be deserialized into: (0.34, 0.123, 0.542, 0.4143) Obviously I understand that whichever way it's implemented people are going to be upset but I think this is far more common than having a map with keys like |
@Reprevise – hrm. Yeah. Or I could do a list if they are all positional. Hrm. File a separate issue. Happy to entertain for later. |
|
For those who still have this problem, instead of running pub upgrade, which would update a lot of your project's dependencies, you just need to update the package dart_style to the latest version/2.3.2, depending on the version of the package analyzer that you're using |
With the upcoming records feature, it would be good to figure out how to serialize those with this package.
I'd propose:
Allow records with mixed fields with the following qualifications:
Potential other requirements to consider:
Note that we could probably support not requiring to go through a typedef, it just makes it more error prone for users, because they need to understand that the type is not canonicalized and the annotation would have to be added to all records.
Finally, we would need to consider what annotating a record type by itself (not embedded in an object) with JsonSerializable would look like. I think creating a toJson extension method would be a good approach. Where to put the fromJson method / how to name it is a bit more tricky.
The text was updated successfully, but these errors were encountered: