首页 > 解决方案 > Flutter Dart / 数据列表的大小

问题描述

我正在创建一个单词应用程序来学习英语词汇。它基于我计划保存在一个列表中的一个非常大的 Word Bank。(硬编码)。

这个大列表由 Word Objects 组成:

List<Word> wordBank = [
  Word(
    id: 0,
    main: 'alligator',
    articleEng: 'an',
    ortho2: '',
    phon: 'ælɪgeɪtər',
    syllabe: 'alliGAtor',
    son: 'eɪ',
    remPhon: '',
    marqueur: '',
    plur: 'alligators',
    nature: 'noun',
    theme: ['banimals', 'banimaux'],
    subTheme: [
      T(e: 'reptiles', f: 'reptiles'),
      T(e: 'wild animals', f: 'animaux sauvages')
    ],
    level: 2,
    mainFr: 'alligator',
    articleFr: 'un',
    french: [],
    syn: [],
    ant: [],
    wDef:
        'a large reptile similar to a crocodile, with a long tail, hard skin and very big jaws, that lives in rivers and lakes in North and South America and China',
    oDef: '',
    wPhrase: 'There are alligators in this river! Beware!',
    wPhraseFr: 'Il y a des alligators dans cette rivière! Faites attention!',
    oPhrase: '',
    remarque: '',
    past: [],
  ),
]

列表中应该有 2000 到 3000 个这些 Word 对象。我曾尝试使用这样的庞大列表,并且该应用程序运行得相当好。

在安装 FIREBASE(对于应用程序的其他部分)时,我必须授权“multiDexEnabled true”。我读它是因为所有类和方法的总和超过了 64k。

这是因为我的名单很大吗?这到底会不会有问题?当/如果我发布应用程序时会导致问题吗?

标签: listflutterdartsize

解决方案


multiDexEnabled当应用程序中引用超过 64,000 个 JVM 方法时需要。它与任何硬编码数据的大小或与 Dart 相关的任何内容都无关。

这应该不是问题,但是如果您想避免它,可以在Android 开发者网站上尝试一些记录在案的内容。

另一方面,由于您的数据是硬编码的,请尽量使用const


推荐阅读