66library ;
77
88import 'dictionary_lookup_result.dart' ;
9+ import 'dictionary_entry.dart' ;
910
1011/// 提取 [result] 中所有可发音英文文本,按弹窗显示顺序:
1112/// 单词标题 → 各义项例句 → 常见搭配例句 → 词族例句。
@@ -18,19 +19,30 @@ List<String> dictionarySpeakableTexts(DictionaryLookupResult result) {
1819 // 单词标题(跨源恒有,标题行 SpeakButton 发此文本)。
1920 texts.add (result.headword);
2021
21- // 仅 AI 源带例句 ,且各例句均为 _ExampleView 的点击发音目标。
22+ // AI 单词源带例句 ,且各例句均为 _ExampleView 的点击发音目标。
2223 if (result is AiDictResult ) {
23- final entry = result.entry;
24- for (final meaning in entry.meanings) {
25- for (final ex in meaning.examples) {
26- texts.add (ex.sentence);
27- }
28- }
29- for (final expr in entry.commonExpressions) {
30- texts.add (expr.example.sentence);
31- }
32- for (final item in entry.wordFamily) {
33- texts.add (item.example.sentence);
24+ switch (result.entry) {
25+ case final DictionaryEntry entry:
26+ for (final meaning in entry.meanings) {
27+ for (final ex in meaning.examples) {
28+ texts.add (ex.sentence);
29+ }
30+ }
31+ for (final expr in entry.commonExpressions) {
32+ texts.add (expr.example.sentence);
33+ }
34+ for (final item in entry.wordFamily) {
35+ texts.add (item.example.sentence);
36+ }
37+ case final MultiWordDictionaryEntry entry:
38+ for (final meaning in entry.meanings) {
39+ for (final ex in meaning.examples) {
40+ texts.add (ex.sentence);
41+ }
42+ }
43+ for (final expr in entry.similarExpressions) {
44+ texts.add (expr.sentence);
45+ }
3446 }
3547 }
3648
0 commit comments