getMosquitoSpeciesById method
Retrieves a specific mosquito species by ID for a specific language.
Returns a single mosquito species with localized information and associated diseases, or null if not found.
@param id The unique identifier of the mosquito species @param languageCode The language code (e.g., 'en', 'es') @return A Future that completes with a MosquitoSpecies or null
Implementation
Future<MosquitoSpecies?> getMosquitoSpeciesById(String id, String languageCode) async {
final db = await database;
final List<Map<String, dynamic>> maps = await db.rawQuery('''
SELECT
s.id, s.name, s.image_url,
t.common_name, t.description, t.habitat, t.distribution
FROM mosquito_species s
LEFT JOIN mosquito_species_translations t ON s.id = t.species_id
WHERE s.id = ? AND t.language_code = ?
''', [id, languageCode]);
if (maps.isEmpty) return null;
final map = maps.first;
final diseaseNames = await _getDiseaseNamesForMosquito(db, map['id'], languageCode);
return MosquitoSpecies(
id: map['id'],
name: map['name'],
commonName: map['common_name'],
description: map['description'],
habitat: map['habitat'],
distribution: map['distribution'],
imageUrl: map['image_url'],
diseases: diseaseNames,
);
}