【问题标题】:Retrieving a value from a list at specific index从特定索引处的列表中检索值
【发布时间】:2020-10-12 11:34:50
【问题描述】:

(

我对编程很陌生,所以请原谅我的无知,但是我如何在 category_list 索引 1 处检索值“忠诚度”?使用 Flutter (Dart) 我已经尝试过文档,但很遗憾发现自己陷入了困境。

从问题文档中检索图像时,我对下面的代码没有任何问题,并且我正在尝试获得相同的结果。

    final questions = await _firestore
      .collection('questions')
      .document(getCategory)
      .collection(pullLeadership)
      .document('question')
      .get();
  newQuestion = questions.data['$questionNumber'];

【问题讨论】:

  • 尝试:category = categories.data['category_list'][1];
  • 单引号错误。要么使用反引号,要么根本不使用引号newQuestion = questions.data[questionNumber];

标签: list flutter dart google-cloud-firestore


【解决方案1】:

应该是: 类别 = categories.data["category_list"][1];

【讨论】:

    猜你喜欢
    • 2014-05-25
    • 2021-11-17
    • 1970-01-01
    • 2016-01-31
    • 2015-07-27
    • 2019-11-07
    • 2011-11-06
    • 2015-10-13
    • 1970-01-01
    相关资源
    最近更新 更多