I just wanted to update the *.g.dart files because of some model changes when I suddenly got into the issue that it is required to be null-safety. I don't see the necessity to make my project null-safety. I also don't see the necessity for json_serializable to be null-safety. Why is it null-safety?
I really like this package but currently I have to look out for another one. Using some old version where bugs don't get fixed is not an option for me.
Please make it possible to use your package without being null-safety.
json_serializable version: 4.1.0
Flutter version: 2.0.2
Dart version: 2.12.1
Also seeing tons of issues. Wasted days on it.
Sorry, folks. We have to pick one side of null safety to be on – and we picked to be null safe.
The experience is BETTER (in general) with null-safety, but we know the migration can be tricky for folks.
Remember: this is open source software maintained mostly by me in my spare time. You're welcome to fork it and do as you like!
@kevmoo of course; we also picked null safety; but now the library cannot parse a double. If any json comes down as the number 1 for example; it tries to parse int even though the model says double.
For example,
final Map<String, double> muscleGroups; << Not way to generate this code now. The library fails. Tries to parse int on 1
final Map<String, num> muscleGroups; << Invalid code.
@ollydixon – I've been VERY heads down on I/O things the last few weeks.
Did you file a bug for THIS specific issue?
@kevmoo I have not no. I will do it later/tomorrow. :-) (need to hack a solution for this for now)
@kevmoo I have not no. I will do it later/tomorrow. :-) (need to hack a solution for this for now)
I may be able to FIX it for you now, if you give me a repro 😄
Here is an example of code that breaks when parsing json.
@JsonSerializable()
@immutable
class ExerciseV1 {
final Map<String, double> muscleGroups;
}
Too fix we do this; but it's broken for other purposes.
@JsonSerializable()
@immutable
class ExerciseV1 {
final Map<String, number> muscleGroups;
}
The json that breaks is simple:
{
'abs': 1, << fails
'hamstrings': 0.5, << pass
}
Sorry I'm fairly drunk at the moment
Sorry I'm fairly drunk at the moment
🤣
Cheers to you @ollydixon – https://github.com/google/json_serializable.dart/pull/894
Good bug!
@kevmoo thanks for being so responsive hehe :-). Yes indeed; cheers to you too! 🍻
@kevmoo thanks for being so responsive hehe :-). Yes indeed; cheers to you too! 🍻
Now we just need to annoy @jakemac53 and/or @natebosch to approve! 😁
@jakemac53 @natebosch package breaking bug here! 🕺😍
@ollydixon – landed and published!
@kevmoo thanks! :-D
@kevmoo I still don't understand why it is required for MY project to be null-safety just because THIS package is null-safety. Can't this package be null-safety without requiring projects that depend on it to be null-safety?
Isn't possible to add a flag to the specific class or on a 'build.yaml' folder to decline null-safety?
@JoseGeorges8 – sadly, not. It's a DEEP implementation. It's not a simple thing to turn on/off
Most helpful comment
🤣