【发布时间】:2020-09-15 04:13:30
【问题描述】:
我正在尝试在颤振中转换 Stream<List<String>> to List<String>
这是我的代码
Stream<List<String>> _currentEntries;
/// A stream of entries that should be displayed on the home screen.
Stream<List<String>> get categoryEntries => _currentEntries;
_currentEntries 正在填充来自数据库的数据。
我想将_currentEntries 转换为List<String>
我尝试了以下代码但不起作用:
List<List<String>> categoryList () async {
return await _currentEntries.toList();
}
我收到以下错误:
List<List<String>>类型的值无法从方法categoryList返回,因为它的返回类型为List<List<String>>
有人可以帮助解决这个问题并将Stream<List<String> 转换为List<String> 吗?
【问题讨论】:
-
能否分享一下从数据库返回的数据以及您希望如何格式化?
-
@SanjaySharma 问题中解释了数据库中的数据类型。