首页 > 解决方案 > 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 约定不太熟悉,所以如果我违反了任何约定,我很抱歉

标签: flutterdart

解决方案


推荐阅读