Dart 无法识别类型

时间:2021-02-11 12:53:55

标签: flutter dart

这是简化的源代码,我从 firebase 数据库中获取 dataBaseList,我知道它只包含字符串:

List<String> stringList;
stringList = dataBaseList;

它返回这个错误:'List<dynamic>' is not a subtype of type 'List<String>

所以我认为这个解决方案可能会解决问题:

List<String> stringList;
stringList = dataBaseList as List<String>;

但是,它现在返回此错误: type 'List<dynamic>' is not a subtype of type 'List<String>' in type cast

有没有办法解决这个问题?

我不太熟悉 Stackoverflow 约定,所以如果我违反了任何约定,我很抱歉

0 个答案:

没有答案