In Dart we add methods like toJson()
and Model.fromJson()
inside model, does this breaks MVVM or SOLID principles?
CodePudding user response:
No, it doesn't, it's totally the opposite, it's recommended to set model JSON converters factories and methods of a model inside its implementation.
check this:
the goal of those methods is to handle serializing your model, to make your life easier when working with APIs, and external data...
I would say that what's not a good practice, is to try to handle JSON serialization inside your business logic.