【问题标题】:Future<List<Notes>> to Stream so i can use it in stream builderFuture<List<Notes>> 到 Stream 所以我可以在流生成器中使用它
【发布时间】:2021-04-01 13:22:56
【问题描述】:
static String _url = "https://notes-7f146-default-rtdb.firebaseio.com";

static Future browse() async {
    final List<Notes> _notes = [];
    var respose = await http.get(Uri.parse(_url + '/notes.json?'));

    final extractedData =
        await convert.json.decode(respose.body) as Map<String, dynamic>;
    extractedData.forEach((key, value) {
      _notes.add(Notes(
          title: value['title'], desc: value['desc'], key: key.toString()));
    });
    // _notes = collection.map((json) => Notes.fromJson(json)).toList();
    return _notes;
}

我怎样才能从中制作一个流?

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    您可以使用 Stream.fromFuture(dur) 将 Future 转换为 Stream。

    如果您将问题整理成可读的内容,我将能够在此答案中使用它。 ;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-02
      • 2018-07-19
      • 1970-01-01
      • 1970-01-01
      • 2012-09-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-22
      相关资源
      最近更新 更多