class WordItem { final int id; // Base index 0..999 final int sessionNumber; // Dynamic randomized session number 0..999 final String word; final String partOfSpeech; final double frequency; final String category; final String description; const WordItem({ required this.id, this.sessionNumber = 0, required this.word, required this.partOfSpeech, required this.frequency, this.category = '', this.description = '', }); WordItem copyWith({ int? id, int? sessionNumber, String? word, String? partOfSpeech, double? frequency, String? category, String? description, }) { return WordItem( id: id ?? this.id, sessionNumber: sessionNumber ?? this.sessionNumber, word: word ?? this.word, partOfSpeech: partOfSpeech ?? this.partOfSpeech, frequency: frequency ?? this.frequency, category: category ?? this.category, description: description ?? this.description, ); } String get formattedSessionNumber => sessionNumber.toString().padLeft(3, '0'); String get formattedId => formattedSessionNumber; Map toMap() { return { 'id': id, 'sessionNumber': sessionNumber, 'word': word, 'partOfSpeech': partOfSpeech, 'frequency': frequency, 'category': category, 'description': description, }; } factory WordItem.fromMap(Map map) { return WordItem( id: map['id'] as int, sessionNumber: map['sessionNumber'] as int? ?? (map['id'] as int), word: map['word'] as String, partOfSpeech: map['partOfSpeech'] as String, frequency: (map['frequency'] as num).toDouble(), category: map['category'] as String? ?? '', description: map['description'] as String? ?? '', ); } @override String toString() => '#$formattedSessionNumber: $word ($partOfSpeech)'; }