Map<String, dynamic> toJson() => {
"username": username,
"Event_date_time": eventDateTime,
"Event_name": eventName,
"Event_Address": eventAddress,
"Utensils": utensils,
"Hot_serve": hotServe,
"Carting": carting,
"Beverage ": List<dynamic>.from(Beverage.map((x) => x.toJson())),
};
class Beverage {
String beveragesitem;
String beveragesCount;
Beverage({
this.beveragesitem,
this.beveragesCount,
});
factory Beverage.fromJson(Map<String, dynamic> json) => Beverage(
beveragesitem: json["Beveragesitem"],
beveragesCount: json["Beverages_count"],
);
Map<String, dynamic> toJson() => {
"Beveragesitem": beveragesitem,
"Beverages_count": beveragesCount,
};
}
Error showing like below
Unhandled Exception: NoSuchMethodError: The getter 'length' was called on null. E/flutter ( 6308): Receiver: null E/flutter ( 6308): Tried calling: length E/flutter ( 6308): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5) E/flutter ( 6308): #1 _Uri._uriEncode (dart:core-patch/uri_patch.dart:44:23) E/flutter ( 6308): #2 Uri.encodeQueryComponent (dart:core/uri.dart:1103:17) E/flutter ( 6308): #3 mapToQuery. (package:http/src/utils.dart:19:13) E/flutter ( 6308): #4 CastMap.forEach. (dart:_internal/cast.dart:286:8) E/flutter ( 6308): #5 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
Can anyone help correcting this issue?