Disease.fromJson constructor

Disease.fromJson(
  1. Map<String, dynamic> json
)

Creates a Disease from a JSON map.

Used for deserializing disease data from JSON sources such as local asset files or health database APIs.

Example:

final json = {
  'id': 'dengue',
  'name': 'Dengue Fever',
  'description': 'A viral infection...',
  // ... other fields
};
final disease = Disease.fromJson(json);

Implementation

factory Disease.fromJson(Map<String, dynamic> json) {
  return Disease(
    id: json['id'] as String,
    name: json['name'] as String,
    description: json['description'] as String,
    symptoms: json['symptoms'] as String,
    treatment: json['treatment'] as String,
    prevention: json['prevention'] as String,
    vectors: List<String>.from(json['vectors'] as List),
    prevalence: json['prevalence'] as String,
    imageUrl: json['image_url'] as String,
  );
}