Dart ServiceStack client with null safety - It's a pain for me

Unfortunately I am very unhappy with the Null-Safety implementation of generated DTO files from ServiceStack. All properties are declared nullable which means that one has to deal with tons of if()s and clutter the entire code with ! almost everywhere.

Dart sees nullable types as an exception (see this document). I can imagine, that it is not so easy to write a code generator, especially since the topic is new and lots of people struggle and fight with it (like I do still very often).

Maybe a solution could be this package provided by Google. In the sample you can see, that it is able to deal with non-nullable class members.

It uses the build_runner package to generate the code.

I don’t know what you guys think, but for me it is currently easier to use the http package to fire my REST calls and do serialization into my client models myself.

Required properties are incompatible with evolvable message-based APIs and generic service clients.

If you need different generated models you’ll need to adopt a different approach, likely a solution that’s bespoke to each of your APIs like your alternative solution with using the http package directly.