Dart Flutter Base Response Model Class Dynamic

Hello there, i will tell you my problem with class data dynamic in flutter, Yes, it’s quite draining, even though it’s simple at first glance, let me explain
- Make base model with custom map or list
- Create sub model
- Implementation
Make base model of ApiResponse this model will be the parent of other models, do you see callback in parameter fromJson ‘build’, this like make submodel model to parent model, and here there are 2 classes available ApiResponse for single response object, ApiResponseList for array response list, this is made separately to make it simpler and easier to read.
This is a sample model that is always present in every api response, you can change it according to your needs
And then, you need make sub model, example i use this
okay now just implementation easy, let’s just say the response API, like this
and now, you can implementation like this
Thanks
- References — https://stackoverflow.com/a/64596316/13238988