Home > Mobile >  How to check object in model class when its null sometime in response in flutter
How to check object in model class when its null sometime in response in flutter

Time:09-16

Error is shown when subscription object is null which is the required type parameter.

Error: NoSuchMethodError: The method '[]' was called on null. Receiver: null Tried calling:

How to solve this error, arrived on when subscription object is null.

I also shared my model class download link https://drive.google.com/file/d/1gcOKQ49RaEF3w0NBPpijGtbGUdSkgZrx/view?usp=sharing

CodePudding user response:

please try with this

if(json['subscription'] !=null) { subscription = Subscription.fromJson(json['subscription']); }
  • Related