fromMap static method
Implementation
static IsolateEvent fromMap(Map map) {
final event = map['event'] as String?;
switch (event) {
case 'highlight':
return WordMatchedEvent(
wordId: map['word_id'] as int,
score: (map['score'] as num?)?.toDouble() ?? 0.0,
cleanAsr: map['clean_asr'] as String? ?? '',
tajweedErrors: (map['tajweed_errors'] as List?)
?.map((e) => (e as Map).cast<String, dynamic>())
.toList(),
isRed: map['is_red'] as bool? ?? false,
isNeutral: map['is_neutral'] as bool? ?? false,
);
case 'debug':
return DebugLogEvent(
message: map['message'] as String? ?? '',
asrBuffer: map['asr_buffer'] as String? ?? '',
);
default:
throw ArgumentError('Unknown IsolateEvent: $event');
}
}