Here is the error I am getting,
[ERROR:flutter/lib/ui/ui_dart_state.cc(199)]
Unhandled Exception: type '(dynamic) => Null' is not a
subtype of type '(String, dynamic) => void' of 'f'
The getter 'vendorDocList' was called on null.
Receiver: null
Tried calling: vendorDocList
Code:
class VendorsDocument {
String lead_id;
Future<getVendorsDoc> getVendorDocList(lead_id) async {
final response = await http.post(Uri.parse('example.com/vendor_doc'),
headers:{
'Accept': 'application/json',
HttpHeaders.authorizationHeader: 'Bearer $accessToken}',
},
body: {'lead_id':'$lead_id'});
if (response.statusCode == 200) {
// print(response.body);
return getVendorsDoc.fromJson( json.decode(response.body) );
} else {
throw Exception('No records found');
}
}
}
class getVendorsDoc {
bool status;
String msg;
List<VendorDocList> vendorDocList;
getVendorsDoc({this.status, this.msg, this.vendorDocList});
getVendorsDoc.fromJson(Map<String, dynamic> json) {
status = json['status'];
msg = json['message'];
vendorDocList = new List<VendorDocList>();
json['data'].forEach((v) {
vendorDocList.add(new VendorDocList.fromJson(v));
});
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['status'] = this.status;
data['message'] = this.msg;
// if (this.vendorDocList != null) {
data['data'] = this.vendorDocList.map((v) => v.toJson()).toList();
// }
return data;
}
}
class VendorDocList {
String logo;
VendorDocList(
{this.logo});
VendorDocList.fromJson(Map<String, dynamic> json) {
logo = json['logo'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['logo'] = this.logo;
}
}
Please help me to resolve this issueis not a good title for a post. I changed it, please check if it ok to you.