Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 如何从CloudFireStore获取字符串列表?_Flutter_Dart_Flutter Layout - Fatal编程技术网

Flutter 如何从CloudFireStore获取字符串列表?

Flutter 如何从CloudFireStore获取字符串列表?,flutter,dart,flutter-layout,Flutter,Dart,Flutter Layout,我已经添加了CloudFireStore中的兴趣列表。我尽了最大的努力得到这个列表并显示出来。 我使用stream builder获取用户集合中的其他字段。有人能帮我吗 这是集合和文档的外观: 以下是我使用streambuilder获取其他字段的方式: Widget build(BuildContext context) { return StreamBuilder<QuerySnapshot>( stream: myStream, builder: (context, A

我已经添加了CloudFireStore中的兴趣列表。我尽了最大的努力得到这个列表并显示出来。 我使用stream builder获取用户集合中的其他字段。有人能帮我吗

这是集合和文档的外观:

以下是我使用streambuilder获取其他字段的方式:

Widget build(BuildContext context) {
return StreamBuilder<QuerySnapshot>(
  stream: myStream,
  builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {
    return !snapshot.hasData
        ? Center(child: CircularProgressIndicator())
        : Column(
            children: [
                  DocumentSnapshot document = snapshot.data.docs[index];
                  return Stack(
                    alignment: Alignment.topCenter,
                    fit: StackFit.expand,
                    children: [
                      Container(
                        height: screenHeight * 0.65,
                        decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.circular(30),
                          gradient: LinearGradient(
                            begin: FractionalOffset.topCenter,
                            end: FractionalOffset.bottomCenter,
                            colors: [
                              Colors.grey.withOpacity(0.0),
                              Colors.black,
                            ],
                            stops: [0.0, 1.0],
                          ),
                        ),
                        child: Padding(
                          padding: const EdgeInsets.only(bottom: 20),
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.end,
                            children: [
                              Text(
                                toBeginningOfSentenceCase(
                                        '${document.data()['username']}') +
                                    ',  ' +
                                    '${document.data()['age']}',
                                style: TextStyle(
                                    fontSize: 40,
                                    color: Colors.white,
                                    fontWeight: FontWeight.bold),
                              ),
                              
                            ],
                          ),
                        ),
                      ),
                    ],
                  );
小部件构建(构建上下文){
返回流生成器(
流:myStream,
生成器:(上下文,异步快照){
return!snapshot.hasData
?中心(子项:循环压缩机指示器())
:列(
儿童:[
DocumentSnapshot document=snapshot.data.docs[索引];
返回堆栈(
对齐:alignment.topCenter,
fit:StackFit.expand,
儿童:[
容器(
高度:屏幕高度*0.65,
装饰:盒子装饰(
颜色:颜色,白色,
边界半径:边界半径。圆形(30),
梯度:线性梯度(
开始:分馏loffset.topCenter,
结束:分馏loffset.bottomCenter,
颜色:[
颜色。灰色。不透明度(0.0),
颜色,黑色,
],
停止:[0.0,1.0],
),
),
孩子:填充(
填充:仅限常量边集(底部:20),
子:列(
mainAxisAlignment:mainAxisAlignment.end,
儿童:[
正文(
开始审理案件(
“${document.data()['username']}”)+
',  ' +
“${document.data()['age']}”,
样式:TextStyle(
尺寸:40,
颜色:颜色,白色,
fontWeight:fontWeight.bold),
),
],
),
),
),
],
);

Wich fileds,您遇到了什么错误?我已经使用文本小部件显示了用户名和年龄字段,但我不知道是否可以获取interets字段的列表。您想在文本或简单文本小部件中显示它们吗?是的。我尝试了以下操作:text(“$document.data()[‘interets’,”)。这是在括号中显示的结果,如下所示:[食物,生活,骑自行车]。我用括号发短信。