Files
Auto-GPT/frontend/lib/models/skill_tree/info.dart
hunteraraujo 3c35cab55e Enhance Info model to handle optional JSON fields gracefully
This commit updates the Info class to provide default values for optional or missing fields in the JSON payload. This ensures that the model can be successfully instantiated even when some JSON fields are absent or set to null.
2023-09-13 17:30:41 -07:00

20 lines
450 B
Dart

class Info {
final String difficulty;
final String description;
final List<String> sideEffects;
Info({
required this.difficulty,
required this.description,
required this.sideEffects,
});
factory Info.fromJson(Map<String, dynamic> json) {
return Info(
difficulty: json['difficulty'] ?? "",
description: json['description'] ?? "",
sideEffects: List<String>.from(json['side_effects'] ?? []),
);
}
}