I always get the error The argument type 'dynamic' cannot be assigned to the parameter type 'Iterable' for the line json["geraete"].map((x) => RDevice.fromJson(x)), can someone help me?
factory Reservation.fromJson(Map<String, dynamic> json) => Reservation(*emphasized text*
resNr: json['resNr'] as int,
vbid: json['vbid'] as int,
benutzer: json['benutzer'] as String,
geraete: List<RDevice>.from(**json["geraete"].map((x) => RDevice.fromJson(x))**),
von: json['von'] as String,
bis: json['bis'] as String,
abgabe: json['abgabe'] as String,
abholung: json['abholung'] as String,
rdatum: json['rdatum'] as String,
status: json['status'] as String,
startTime: json['startTime'] as int, // slot nummer
endTime: json['endTime'] as int,
);
Here is the part from my RDevice class
factory RDevice.fromJson(Map<String, dynamic> json) => RDevice(
id: json['id'] as int,
resid: json['resid'] as int,
deviceid: json['geraetid'] as int,
description: json['bezeichnung'] as String,
);
CodePudding user response:
Try to change it to
geraete: List<RDevice>.from((json["geraete"] as List<Map<String, dynamic>>).map((x) => RDevice.fromJson(x))),